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 | |
45 | /*----------------------------------------------------------------------*/ |
46 | /* |
47 | * Includes |
48 | */ |
49 | |
50 | #include <OpenGl_tgl_all.hxx> |
51 | |
52 | #include <GL/gl.h> |
53 | |
54 | |
55 | /*----------------------------------------------------------------------*/ |
56 | /* |
57 | * Constantes |
58 | */ |
59 | |
60 | typedef int TextureID; |
61 | #define TEXTUREBOX_ERROR ((TextureID)-1) |
62 | |
63 | /* |
64 | * Structure |
65 | */ |
66 | struct _TextureData |
67 | { |
68 | /* Donnees propre au fichier */ |
69 | char path[256]; |
70 | |
71 | /* Donnees propre a la texture */ |
72 | GLint gen; |
73 | GLint wrap; |
74 | GLfloat plane1[4], plane2[4]; |
75 | GLint render; |
76 | GLfloat scalex, scaley; |
77 | GLfloat transx, transy; |
78 | GLfloat angle; |
79 | IMPLEMENT_MEMORY_OPERATORS |
80 | }; |
81 | typedef _TextureData TextureData; |
82 | |
83 | /*----------------------------------------------------------------------*/ |
84 | /* |
85 | * Prototypes |
86 | */ |
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, GLfloat sparams[4], GLfloat tparams[4]); |
125 | void SetModeSphere(TextureID ID); |
126 | void SetModeEye(TextureID ID, GLfloat sparams[4], 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_ */ |