0023022: This is desirable to access OpenGl extensions and core API (1.2+) in one...
[occt.git] / src / OpenGl / OpenGl_TextureBox.hxx
CommitLineData
7fd59977 1/*
2* Fonction
3* ~~~~~~~~
4* Gestion des textures sous OpenGL
5*
6*
7* Notes
8* ~~~~~
9* Les textures sont toujours initialisee avec des parametres par defaut
10* texture 1D: WRAP_S = CLAMP
11* MAG_FILTER = NEAREST
12* generation de texture automatique en OBJECT_LINEAR
13* rendu avec DECAL
14*
15* texture 2D: WRAP_S/T = REPEAT
16* MAG/MIN_FILTER = LINEAR
17* generation de texture automatique en OBJECT_LINEAR
18* rendu avec MODULATE
19*
20* texture 2D MipMap: WRAP_S/T = REPEAT
21* MAG_FILTER = LINEAR
22* MIN_FILTER = LINEAR_MIPMAP_NEAREST
23* generation de texture automatique en OBJECT_LINEAR
24* rendu avec MODULATE
25*
26*
27* Attention:
28* ~~~~~~~~~~~
29* Ce package a ete teste sur SGI, OSF, SUN, HP et WNT.
30*
31*
32* Historique des modifications
33* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34* 22-05-97: PCT ; creation
35* 01-08-97: PCT ; suppression InitializeTextureBox()
36* 05-08-97: FMN ; ajout GetTextureData...
37* 19-06-98: FMN ; Portage Optimizer (C++)
38* 22-07-98: FGU ; ajout stucture TextureData
39*/
40/*----------------------------------------------------------------------*/
41
42#ifndef _OPENGL_TEXTUREBOX_H_
43#define _OPENGL_TEXTUREBOX_H_
44
5f8b738e 45#include <OpenGl_GlCore11.hxx>
1c35b92f 46#include <Standard_DefineAlloc.hxx>
7fd59977 47
7fd59977 48typedef int TextureID;
49#define TEXTUREBOX_ERROR ((TextureID)-1)
50
51/*
52* Structure
53*/
54struct _TextureData
55{
56 /* Donnees propre au fichier */
57 char path[256];
58
59 /* Donnees propre a la texture */
60 GLint gen;
61 GLint wrap;
62 GLfloat plane1[4], plane2[4];
63 GLint render;
64 GLfloat scalex, scaley;
65 GLfloat transx, transy;
66 GLfloat angle;
1c35b92f 67 DEFINE_STANDARD_ALLOC
7fd59977 68};
69typedef _TextureData TextureData;
70
7fd59977 71/*
72* Gestion des textures
73*/
74
75/* Get texture a partir d'un nom de fichier */
76TextureID GetTexture1D(char *FileName);
77TextureID GetTexture2D(char *FileName);
78TextureID GetTexture2DMipMap(char *FileName);
79
80/* Get texture a partir des donnees (format RGBA) GLubyte data[width][height][4]
81* Le nom est utiliser pour la gesiton en interne, il permet d'eviter de charger
82* plusieurs textures avec le meme noms.
83*/
84TextureID GetTextureData1D(char *FileName, const GLint width, const GLint height, const void *data);
85TextureID GetTextureData2D(char *FileName, const GLint width, const GLint height, const void *data);
86TextureID GetTextureData2DMipMap(char *FileName, const GLint width, const GLint height, const void *data);
87
88void FreeTexture(TextureID ID);
89
90void SetCurrentTexture(TextureID ID);
91GLboolean IsTextureValid(TextureID ID);
92
93void EnableTexture(void);
94void DisableTexture(void);
95GLboolean IsTextureEnabled(void);
96
97/*
98* Configuration d'une texture
99*/
100
101void SetTextureModulate(TextureID ID);
102void SetTextureDecal(TextureID ID);
103
104void SetTextureClamp(TextureID ID);
105void SetTextureRepeat(TextureID ID);
106
5f8b738e 107void SetModeObject(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]);
7fd59977 108void SetModeSphere(TextureID ID);
5f8b738e 109void SetModeEye(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]);
7fd59977 110void SetModeManual(TextureID ID);
111
112void SetRenderNearest(TextureID ID);
113void SetRenderLinear(TextureID ID);
114
115
116void SetTexturePosition(TextureID ID,
117 GLfloat scalex, GLfloat scaley,
118 GLfloat transx, GLfloat transy,
119 GLfloat angle);
120
121
122void SetTextureDefaultParams(TextureID ID);
123
124void TransferTexture_To_Data(TextureID, TextureData *);
125void TransferData_To_Texture(TextureData*, TextureID*);
126
127/*----------------------------------------------------------------------*/
128
129#endif /* _OPENGL_TEXTUREBOX_H_ */