b311480e |
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 | |
7fd59977 |
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 | |
5f8b738e |
62 | #include <OpenGl_GlCore11.hxx> |
1c35b92f |
63 | #include <Standard_DefineAlloc.hxx> |
7fd59977 |
64 | |
7fd59977 |
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; |
1c35b92f |
84 | DEFINE_STANDARD_ALLOC |
7fd59977 |
85 | }; |
86 | typedef _TextureData TextureData; |
87 | |
7fd59977 |
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 | |
5e27df78 |
105 | class Handle(OpenGl_Context); |
106 | void FreeTexture (const Handle(OpenGl_Context)& theContext, |
107 | TextureID ID); |
7fd59977 |
108 | |
109 | void SetCurrentTexture(TextureID ID); |
110 | GLboolean IsTextureValid(TextureID ID); |
111 | |
112 | void EnableTexture(void); |
113 | void DisableTexture(void); |
114 | GLboolean IsTextureEnabled(void); |
115 | |
116 | /* |
117 | * Configuration d'une texture |
118 | */ |
119 | |
120 | void SetTextureModulate(TextureID ID); |
121 | void SetTextureDecal(TextureID ID); |
122 | |
123 | void SetTextureClamp(TextureID ID); |
124 | void SetTextureRepeat(TextureID ID); |
125 | |
5f8b738e |
126 | void SetModeObject(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]); |
7fd59977 |
127 | void SetModeSphere(TextureID ID); |
5f8b738e |
128 | void SetModeEye(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]); |
7fd59977 |
129 | void SetModeManual(TextureID ID); |
130 | |
131 | void SetRenderNearest(TextureID ID); |
132 | void SetRenderLinear(TextureID ID); |
133 | |
134 | |
135 | void SetTexturePosition(TextureID ID, |
136 | GLfloat scalex, GLfloat scaley, |
137 | GLfloat transx, GLfloat transy, |
138 | GLfloat angle); |
139 | |
140 | |
141 | void SetTextureDefaultParams(TextureID ID); |
142 | |
143 | void TransferTexture_To_Data(TextureID, TextureData *); |
7fd59977 |
144 | |
145 | /*----------------------------------------------------------------------*/ |
146 | |
147 | #endif /* _OPENGL_TEXTUREBOX_H_ */ |