0023186: Unable to display Graphic3d_ArrayOfPoints after migrating from OCCT 6.5.2
[occt.git] / src / OpenGl / OpenGl_TextureBox.hxx
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
65 typedef int TextureID;
66 #define TEXTUREBOX_ERROR ((TextureID)-1)
67
68 /*
69 *  Structure
70 */
71 struct _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 };
86 typedef _TextureData TextureData;
87
88 /* 
89 * Gestion des textures
90 */
91
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);
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 */
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);
104
105 void FreeTexture(TextureID ID);
106
107 void SetCurrentTexture(TextureID ID);
108 GLboolean IsTextureValid(TextureID ID);
109
110 void EnableTexture(void);
111 void DisableTexture(void);
112 GLboolean IsTextureEnabled(void);
113
114 /* 
115 * Configuration d'une texture 
116 */
117
118 void SetTextureModulate(TextureID ID);
119 void SetTextureDecal(TextureID ID);
120
121 void SetTextureClamp(TextureID ID);
122 void SetTextureRepeat(TextureID ID);
123
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);
128
129 void SetRenderNearest(TextureID ID);
130 void SetRenderLinear(TextureID ID);
131
132
133 void SetTexturePosition(TextureID ID,
134                         GLfloat scalex, GLfloat scaley,
135                         GLfloat transx, GLfloat transy,
136                         GLfloat angle);
137
138
139 void SetTextureDefaultParams(TextureID ID);
140
141 void TransferTexture_To_Data(TextureID, TextureData *);
142 void TransferData_To_Texture(TextureData*, TextureID*);
143
144 /*----------------------------------------------------------------------*/
145
146 #endif /* _OPENGL_TEXTUREBOX_H_ */