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 d'un nom de fichier */
93 TextureID GetTexture1D(char *FileName);
94 TextureID GetTexture2D(char *FileName);
95 TextureID GetTexture2DMipMap(char *FileName);
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.
101 TextureID GetTextureData1D(char *FileName, const GLint width, const GLint height, const void *data);
102 TextureID GetTextureData2D(char *FileName, const GLint width, const GLint height, const void *data);
103 TextureID GetTextureData2DMipMap(char *FileName, const GLint width, const GLint height, const void *data);
105 void FreeTexture(TextureID ID);
107 void SetCurrentTexture(TextureID ID);
108 GLboolean IsTextureValid(TextureID ID);
110 void EnableTexture(void);
111 void DisableTexture(void);
112 GLboolean IsTextureEnabled(void);
115 * Configuration d'une texture
118 void SetTextureModulate(TextureID ID);
119 void SetTextureDecal(TextureID ID);
121 void SetTextureClamp(TextureID ID);
122 void SetTextureRepeat(TextureID ID);
124 void SetModeObject(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]);
125 void SetModeSphere(TextureID ID);
126 void SetModeEye(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]);
127 void SetModeManual(TextureID ID);
129 void SetRenderNearest(TextureID ID);
130 void SetRenderLinear(TextureID ID);
133 void SetTexturePosition(TextureID ID,
134 GLfloat scalex, GLfloat scaley,
135 GLfloat transx, GLfloat transy,
139 void SetTextureDefaultParams(TextureID ID);
141 void TransferTexture_To_Data(TextureID, TextureData *);
142 void TransferData_To_Texture(TextureData*, TextureID*);
144 /*----------------------------------------------------------------------*/
146 #endif /* _OPENGL_TEXTUREBOX_H_ */