1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
21 * Gestion des textures sous OpenGL
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
32 * texture 2D: WRAP_S/T = REPEAT
33 * MAG/MIN_FILTER = LINEAR
34 * generation de texture automatique en OBJECT_LINEAR
37 * texture 2D MipMap: WRAP_S/T = REPEAT
39 * MIN_FILTER = LINEAR_MIPMAP_NEAREST
40 * generation de texture automatique en OBJECT_LINEAR
46 * Ce package a ete teste sur SGI, OSF, SUN, HP et WNT.
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
57 /*----------------------------------------------------------------------*/
59 #ifndef _OPENGL_TEXTUREBOX_H_
60 #define _OPENGL_TEXTUREBOX_H_
62 #include <OpenGl_GlCore11.hxx>
63 #include <Standard_DefineAlloc.hxx>
65 typedef int TextureID;
66 #define TEXTUREBOX_ERROR ((TextureID)-1)
73 /* Donnees propre au fichier */
76 /* Donnees propre a la texture */
79 GLfloat plane1[4], plane2[4];
81 GLfloat scalex, scaley;
82 GLfloat transx, transy;
86 typedef _TextureData TextureData;
89 * Gestion des textures
92 /* Get texture a partir des donnees (format RGBA) GLubyte data[width][height][4]
93 * Le nom est utiliser pour la gesiton en interne, il permet d'eviter de charger
94 * plusieurs textures avec le meme noms.
96 TextureID GetTextureData1D(char *FileName, const GLint width, const GLint height, const void *data);
97 TextureID GetTextureData2D(char *FileName, const GLint width, const GLint height, const void *data);
98 TextureID GetTextureData2DMipMap(char *FileName, const GLint width, const GLint height, const void *data);
100 class Handle(OpenGl_Context);
101 void FreeTexture (const Handle(OpenGl_Context)& theContext,
104 void SetCurrentTexture(TextureID ID);
105 GLboolean IsTextureValid(TextureID ID);
107 void EnableTexture(void);
108 void DisableTexture(void);
109 GLboolean IsTextureEnabled(void);
112 * Configuration d'une texture
115 void SetTextureModulate(TextureID ID);
116 void SetTextureDecal(TextureID ID);
118 void SetTextureClamp(TextureID ID);
119 void SetTextureRepeat(TextureID ID);
121 void SetModeObject(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]);
122 void SetModeSphere(TextureID ID);
123 void SetModeEye(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]);
124 void SetModeManual(TextureID ID);
126 void SetRenderNearest(TextureID ID);
127 void SetRenderLinear(TextureID ID);
130 void SetTexturePosition(TextureID ID,
131 GLfloat scalex, GLfloat scaley,
132 GLfloat transx, GLfloat transy,
136 void SetTextureDefaultParams(TextureID ID);
138 void TransferTexture_To_Data(TextureID, TextureData *);
140 /*----------------------------------------------------------------------*/
142 #endif /* _OPENGL_TEXTUREBOX_H_ */