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 |
48 | typedef int TextureID; |
49 | #define TEXTUREBOX_ERROR ((TextureID)-1) |
50 | |
51 | /* |
52 | * Structure |
53 | */ |
54 | struct _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 | }; |
69 | typedef _TextureData TextureData; |
70 | |
7fd59977 |
71 | /* |
72 | * Gestion des textures |
73 | */ |
74 | |
75 | /* Get texture a partir d'un nom de fichier */ |
76 | TextureID GetTexture1D(char *FileName); |
77 | TextureID GetTexture2D(char *FileName); |
78 | TextureID 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 | */ |
84 | TextureID GetTextureData1D(char *FileName, const GLint width, const GLint height, const void *data); |
85 | TextureID GetTextureData2D(char *FileName, const GLint width, const GLint height, const void *data); |
86 | TextureID GetTextureData2DMipMap(char *FileName, const GLint width, const GLint height, const void *data); |
87 | |
88 | void FreeTexture(TextureID ID); |
89 | |
90 | void SetCurrentTexture(TextureID ID); |
91 | GLboolean IsTextureValid(TextureID ID); |
92 | |
93 | void EnableTexture(void); |
94 | void DisableTexture(void); |
95 | GLboolean IsTextureEnabled(void); |
96 | |
97 | /* |
98 | * Configuration d'une texture |
99 | */ |
100 | |
101 | void SetTextureModulate(TextureID ID); |
102 | void SetTextureDecal(TextureID ID); |
103 | |
104 | void SetTextureClamp(TextureID ID); |
105 | void SetTextureRepeat(TextureID ID); |
106 | |
5f8b738e |
107 | void SetModeObject(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]); |
7fd59977 |
108 | void SetModeSphere(TextureID ID); |
5f8b738e |
109 | void SetModeEye(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]); |
7fd59977 |
110 | void SetModeManual(TextureID ID); |
111 | |
112 | void SetRenderNearest(TextureID ID); |
113 | void SetRenderLinear(TextureID ID); |
114 | |
115 | |
116 | void SetTexturePosition(TextureID ID, |
117 | GLfloat scalex, GLfloat scaley, |
118 | GLfloat transx, GLfloat transy, |
119 | GLfloat angle); |
120 | |
121 | |
122 | void SetTextureDefaultParams(TextureID ID); |
123 | |
124 | void TransferTexture_To_Data(TextureID, TextureData *); |
125 | void TransferData_To_Texture(TextureData*, TextureID*); |
126 | |
127 | /*----------------------------------------------------------------------*/ |
128 | |
129 | #endif /* _OPENGL_TEXTUREBOX_H_ */ |