0023428: Extend OpenGl_Context to use Geometry Shaders extension
[occt.git] / src / OpenGl / OpenGl_TextureBox.hxx
... / ...
CommitLineData
1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
18/*
19* Fonction
20* ~~~~~~~~
21* Gestion des textures sous OpenGL
22*
23*
24* Notes
25* ~~~~~
26* Les textures sont toujours initialisee avec des parametres par defaut
27* texture 1D: WRAP_S = CLAMP
28* MAG_FILTER = NEAREST
29* generation de texture automatique en OBJECT_LINEAR
30* rendu avec DECAL
31*
32* texture 2D: WRAP_S/T = REPEAT
33* MAG/MIN_FILTER = LINEAR
34* generation de texture automatique en OBJECT_LINEAR
35* rendu avec MODULATE
36*
37* texture 2D MipMap: WRAP_S/T = REPEAT
38* MAG_FILTER = LINEAR
39* MIN_FILTER = LINEAR_MIPMAP_NEAREST
40* generation de texture automatique en OBJECT_LINEAR
41* rendu avec MODULATE
42*
43*
44* Attention:
45* ~~~~~~~~~~~
46* Ce package a ete teste sur SGI, OSF, SUN, HP et WNT.
47*
48*
49* Historique des modifications
50* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51* 22-05-97: PCT ; creation
52* 01-08-97: PCT ; suppression InitializeTextureBox()
53* 05-08-97: FMN ; ajout GetTextureData...
54* 19-06-98: FMN ; Portage Optimizer (C++)
55* 22-07-98: FGU ; ajout stucture TextureData
56*/
57/*----------------------------------------------------------------------*/
58
59#ifndef _OPENGL_TEXTUREBOX_H_
60#define _OPENGL_TEXTUREBOX_H_
61
62#include <OpenGl_GlCore11.hxx>
63#include <Standard_DefineAlloc.hxx>
64
65typedef int TextureID;
66#define TEXTUREBOX_ERROR ((TextureID)-1)
67
68/*
69* Structure
70*/
71struct _TextureData
72{
73 /* Donnees propre au fichier */
74 char path[256];
75
76 /* Donnees propre a la texture */
77 GLint gen;
78 GLint wrap;
79 GLfloat plane1[4], plane2[4];
80 GLint render;
81 GLfloat scalex, scaley;
82 GLfloat transx, transy;
83 GLfloat angle;
84 DEFINE_STANDARD_ALLOC
85};
86typedef _TextureData TextureData;
87
88/*
89* Gestion des textures
90*/
91
92/* Get texture a partir d'un nom de fichier */
93TextureID GetTexture1D(char *FileName);
94TextureID GetTexture2D(char *FileName);
95TextureID GetTexture2DMipMap(char *FileName);
96
97/* Get texture a partir des donnees (format RGBA) GLubyte data[width][height][4]
98* Le nom est utiliser pour la gesiton en interne, il permet d'eviter de charger
99* plusieurs textures avec le meme noms.
100*/
101TextureID GetTextureData1D(char *FileName, const GLint width, const GLint height, const void *data);
102TextureID GetTextureData2D(char *FileName, const GLint width, const GLint height, const void *data);
103TextureID GetTextureData2DMipMap(char *FileName, const GLint width, const GLint height, const void *data);
104
105class Handle(OpenGl_Context);
106void FreeTexture (const Handle(OpenGl_Context)& theContext,
107 TextureID ID);
108
109void SetCurrentTexture(TextureID ID);
110GLboolean IsTextureValid(TextureID ID);
111
112void EnableTexture(void);
113void DisableTexture(void);
114GLboolean IsTextureEnabled(void);
115
116/*
117* Configuration d'une texture
118*/
119
120void SetTextureModulate(TextureID ID);
121void SetTextureDecal(TextureID ID);
122
123void SetTextureClamp(TextureID ID);
124void SetTextureRepeat(TextureID ID);
125
126void SetModeObject(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]);
127void SetModeSphere(TextureID ID);
128void SetModeEye(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]);
129void SetModeManual(TextureID ID);
130
131void SetRenderNearest(TextureID ID);
132void SetRenderLinear(TextureID ID);
133
134
135void SetTexturePosition(TextureID ID,
136 GLfloat scalex, GLfloat scaley,
137 GLfloat transx, GLfloat transy,
138 GLfloat angle);
139
140
141void SetTextureDefaultParams(TextureID ID);
142
143void TransferTexture_To_Data(TextureID, TextureData *);
144
145/*----------------------------------------------------------------------*/
146
147#endif /* _OPENGL_TEXTUREBOX_H_ */