summaryrefslogtreecommitdiff
path: root/inc/OpenGl_TextureBox.hxx
blob: 2095783c9057d37af6a19ede487de961aeed14a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* Fonction
* ~~~~~~~~
*   Gestion des textures sous OpenGL
*
*
* Notes
* ~~~~~
*   Les textures sont toujours initialisee avec des parametres par defaut
*     texture 1D:        WRAP_S = CLAMP
*                        MAG_FILTER = NEAREST
*                        generation de texture automatique en OBJECT_LINEAR
*                        rendu avec DECAL
*
*     texture 2D:        WRAP_S/T = REPEAT
*                        MAG/MIN_FILTER = LINEAR
*                        generation de texture automatique en OBJECT_LINEAR
*                        rendu avec MODULATE
*
*     texture 2D MipMap: WRAP_S/T = REPEAT
*                        MAG_FILTER = LINEAR
*                        MIN_FILTER = LINEAR_MIPMAP_NEAREST
*                        generation de texture automatique en OBJECT_LINEAR
*                        rendu avec MODULATE
*
*
* Attention:
* ~~~~~~~~~~~
*  Ce package a ete teste sur SGI, OSF, SUN, HP et WNT.
*
*
* Historique des modifications
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*   22-05-97: PCT ; creation
*   01-08-97: PCT ; suppression InitializeTextureBox()
*   05-08-97: FMN ; ajout GetTextureData...
*   19-06-98: FMN ; Portage Optimizer (C++)
*   22-07-98: FGU ; ajout stucture TextureData
*/
/*----------------------------------------------------------------------*/

#ifndef _OPENGL_TEXTUREBOX_H_
#define _OPENGL_TEXTUREBOX_H_

/*----------------------------------------------------------------------*/
/*
* Includes
*/

#include <OpenGl_tgl_all.hxx>

#include <GL/gl.h>


/*----------------------------------------------------------------------*/
/*
* Constantes
*/

typedef int TextureID;
#define TEXTUREBOX_ERROR ((TextureID)-1)

/*
*  Structure
*/
struct _TextureData
{
  /* Donnees propre au fichier */
  char path[256];    

  /* Donnees propre a la texture */
  GLint gen;
  GLint wrap;
  GLfloat plane1[4],  plane2[4];
  GLint render;
  GLfloat scalex,  scaley;
  GLfloat transx, transy;
  GLfloat angle;
  IMPLEMENT_MEMORY_OPERATORS
};
typedef _TextureData TextureData;

/*----------------------------------------------------------------------*/
/*
* Prototypes
*/

/* 
* Gestion des textures
*/

/* Get texture a partir d'un nom de fichier */
TextureID GetTexture1D(char *FileName);
TextureID GetTexture2D(char *FileName);
TextureID GetTexture2DMipMap(char *FileName);

/* Get texture a partir des donnees (format RGBA) GLubyte data[width][height][4] 
* Le nom est utiliser pour la gesiton en interne, il permet d'eviter de charger
* plusieurs textures avec le meme noms.
*/
TextureID GetTextureData1D(char *FileName, const GLint width, const GLint height, const void *data);
TextureID GetTextureData2D(char *FileName, const GLint width, const GLint height, const void *data);
TextureID GetTextureData2DMipMap(char *FileName, const GLint width, const GLint height, const void *data);

void FreeTexture(TextureID ID);

void SetCurrentTexture(TextureID ID);
GLboolean IsTextureValid(TextureID ID);

void EnableTexture(void);
void DisableTexture(void);
GLboolean IsTextureEnabled(void);

/* 
* Configuration d'une texture 
*/

void SetTextureModulate(TextureID ID);
void SetTextureDecal(TextureID ID);

void SetTextureClamp(TextureID ID);
void SetTextureRepeat(TextureID ID);

void SetModeObject(TextureID ID, GLfloat sparams[4], GLfloat tparams[4]);
void SetModeSphere(TextureID ID);
void SetModeEye(TextureID ID, GLfloat sparams[4], GLfloat tparams[4]);
void SetModeManual(TextureID ID);

void SetRenderNearest(TextureID ID);
void SetRenderLinear(TextureID ID);


void SetTexturePosition(TextureID ID,
                        GLfloat scalex, GLfloat scaley,
                        GLfloat transx, GLfloat transy,
                        GLfloat angle);


void SetTextureDefaultParams(TextureID ID);

void TransferTexture_To_Data(TextureID, TextureData *);
void TransferData_To_Texture(TextureData*, TextureID*);

/*----------------------------------------------------------------------*/

#endif /* _OPENGL_TEXTUREBOX_H_ */