now uses hardware transforms
[divverent/darkplaces.git] / glquake.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 #ifndef GLQUAKE_H
22 #define GLQUAKE_H
23
24 // disable data conversion warnings
25
26 #ifdef _MSC_VER
27 #pragma warning(disable : 4244)     // LordHavoc: MSVC++ 4 x86, double/float
28 #pragma warning(disable : 4305)         // LordHavoc: MSVC++ 6 x86, double/float
29 #pragma warning(disable : 4018)         // LordHavoc: MSVC++ 4 x86, signed/unsigned mismatch
30 #endif
31
32 #ifdef _WIN32
33 #include <windows.h>
34 #define strcasecmp stricmp
35 #define strncasecmp strnicmp
36 #endif
37
38 //#include <GL/gl.h>
39
40 extern qboolean isG200;
41 extern qboolean isRagePro;
42
43 //====================================================
44
45 extern const char *gl_vendor;
46 extern const char *gl_renderer;
47 extern const char *gl_version;
48 extern const char *gl_extensions;
49
50 void GL_OpenLibrary(void);
51 void GL_CloseLibrary(void);
52 void *GL_GetProcAddress(char *name);
53
54 // wgl uses APIENTRY
55 #ifndef APIENTRY
56 #define APIENTRY
57 #endif
58
59 // for platforms (wgl) that do not use GLAPIENTRY
60 #ifndef GLAPIENTRY
61 #define GLAPIENTRY APIENTRY
62 #endif
63
64 #ifndef GL_PROJECTION
65 typedef unsigned int GLenum;
66 typedef unsigned char GLboolean;
67 typedef unsigned int GLbitfield;
68 typedef void GLvoid;
69 // 1-byte signed
70 typedef signed char GLbyte;
71 // 2-byte signed
72 typedef short GLshort;
73 // 4-byte signed
74 typedef int GLint;
75 // 1-byte unsigned
76 typedef unsigned char GLubyte;
77 // 2-byte unsigned
78 typedef unsigned short GLushort;
79 // 4-byte unsigned
80 typedef unsigned int GLuint;
81 // 4-byte signed
82 typedef int GLsizei;
83 // single precision float
84 typedef float GLfloat;
85 // single precision float in [0,1]
86 typedef float GLclampf;
87 // double precision float
88 typedef double GLdouble;
89 // double precision float in [0,1]
90 typedef double GLclampd;
91
92 #define GL_MODELVIEW                            0x1700
93 #define GL_PROJECTION                           0x1701
94 #define GL_TEXTURE                              0x1702
95 #define GL_MATRIX_MODE                          0x0BA0
96 #define GL_MODELVIEW_MATRIX                     0x0BA6
97 #define GL_PROJECTION_MATRIX                    0x0BA7
98 #define GL_TEXTURE_MATRIX                       0x0BA8
99
100 #define GL_DEPTH_TEST                           0x0B71
101
102 #define GL_CULL_FACE                            0x0B44
103
104 #define GL_BLEND                                0x0BE2
105
106 #define GL_ZERO                                 0x0
107 #define GL_ONE                                  0x1
108 #define GL_SRC_COLOR                            0x0300
109 #define GL_ONE_MINUS_SRC_COLOR                  0x0301
110 #define GL_DST_COLOR                            0x0306
111 #define GL_ONE_MINUS_DST_COLOR                  0x0307
112 #define GL_SRC_ALPHA                            0x0302
113 #define GL_ONE_MINUS_SRC_ALPHA                  0x0303
114 #define GL_DST_ALPHA                            0x0304
115 #define GL_ONE_MINUS_DST_ALPHA                  0x0305
116 #define GL_SRC_ALPHA_SATURATE                   0x0308
117 #define GL_CONSTANT_COLOR                       0x8001
118 #define GL_ONE_MINUS_CONSTANT_COLOR             0x8002
119 #define GL_CONSTANT_ALPHA                       0x8003
120 #define GL_ONE_MINUS_CONSTANT_ALPHA             0x8004
121
122 #define GL_TEXTURE_ENV                          0x2300
123 #define GL_TEXTURE_ENV_MODE                     0x2200
124 #define GL_TEXTURE_1D                           0x0DE0
125 #define GL_TEXTURE_2D                           0x0DE1
126 #define GL_TEXTURE_WRAP_S                       0x2802
127 #define GL_TEXTURE_WRAP_T                       0x2803
128 #define GL_TEXTURE_MAG_FILTER                   0x2800
129 #define GL_TEXTURE_MIN_FILTER                   0x2801
130
131 #define GL_NEAREST                              0x2600
132 #define GL_LINEAR                               0x2601
133 #define GL_NEAREST_MIPMAP_NEAREST               0x2700
134 #define GL_NEAREST_MIPMAP_LINEAR                0x2702
135 #define GL_LINEAR_MIPMAP_NEAREST                0x2701
136 #define GL_LINEAR_MIPMAP_LINEAR                 0x2703
137
138 #define GL_DECAL                                0x2101
139 #define GL_MODULATE                             0x2100
140
141 #define GL_REPEAT                               0x2901
142 #define GL_CLAMP                                0x2900
143
144 #define GL_TRIANGLES                            0x0004
145
146 #define GL_FALSE                                0x0
147 #define GL_TRUE                                 0x1
148
149 #define GL_BYTE                                 0x1400
150 #define GL_UNSIGNED_BYTE                        0x1401
151 #define GL_SHORT                                0x1402
152 #define GL_UNSIGNED_SHORT                       0x1403
153 #define GL_INT                                  0x1404
154 #define GL_UNSIGNED_INT                         0x1405
155 #define GL_FLOAT                                0x1406
156 #define GL_DOUBLE                               0x140A
157 #define GL_2_BYTES                              0x1407
158 #define GL_3_BYTES                              0x1408
159 #define GL_4_BYTES                              0x1409
160
161 #define GL_VERTEX_ARRAY                         0x8074
162 #define GL_NORMAL_ARRAY                         0x8075
163 #define GL_COLOR_ARRAY                          0x8076
164 //#define GL_INDEX_ARRAY                                0x8077
165 #define GL_TEXTURE_COORD_ARRAY                  0x8078
166 //#define GL_EDGE_FLAG_ARRAY                    0x8079
167
168 #define GL_FRONT                                0x0404
169 #define GL_BACK                                 0x0405
170
171 #define GL_VENDOR                               0x1F00
172 #define GL_RENDERER                             0x1F01
173 #define GL_VERSION                              0x1F02
174 #define GL_EXTENSIONS                           0x1F03
175
176 #define GL_NO_ERROR                             0x0
177 #define GL_INVALID_VALUE                        0x0501
178 #define GL_INVALID_ENUM                         0x0500
179 #define GL_INVALID_OPERATION                    0x0502
180 #define GL_STACK_OVERFLOW                       0x0503
181 #define GL_STACK_UNDERFLOW                      0x0504
182 #define GL_OUT_OF_MEMORY                        0x0505
183
184 #define GL_DITHER                               0x0BD0
185 #define GL_RGB                                  0x1907
186 #define GL_RGBA                                 0x1908
187
188 #define GL_MAX_TEXTURE_SIZE                     0x0D33
189
190 #define GL_NEVER                                0x0200
191 #define GL_LESS                                 0x0201
192 #define GL_EQUAL                                0x0202
193 #define GL_LEQUAL                               0x0203
194 #define GL_GREATER                              0x0204
195 #define GL_NOTEQUAL                             0x0205
196 #define GL_GEQUAL                               0x0206
197 #define GL_ALWAYS                               0x0207
198 #define GL_DEPTH_TEST                           0x0B71
199
200 #define GL_RED_SCALE                            0x0D14
201 #define GL_GREEN_SCALE                          0x0D18
202 #define GL_BLUE_SCALE                           0x0D1A
203 #define GL_ALPHA_SCALE                          0x0D1C
204
205 #define GL_DEPTH_BUFFER_BIT                     0x00000100
206 #define GL_ACCUM_BUFFER_BIT                     0x00000200
207 #define GL_STENCIL_BUFFER_BIT                   0x00000400
208 #define GL_COLOR_BUFFER_BIT                     0x00004000
209 #endif
210
211 // GL_ARB_multitexture
212 extern int gl_textureunits;
213 extern void (GLAPIENTRY *qglMultiTexCoord2f) (GLenum, GLfloat, GLfloat);
214 extern void (GLAPIENTRY *qglActiveTexture) (GLenum);
215 extern void (GLAPIENTRY *qglClientActiveTexture) (GLenum);
216 #ifndef GL_ACTIVE_TEXTURE_ARB
217 #define GL_ACTIVE_TEXTURE_ARB                   0x84E0
218 #define GL_CLIENT_ACTIVE_TEXTURE_ARB    0x84E1
219 #define GL_MAX_TEXTURE_UNITS_ARB                0x84E2
220 #define GL_TEXTURE0_ARB                                 0x84C0
221 #define GL_TEXTURE1_ARB                                 0x84C1
222 #define GL_TEXTURE2_ARB                                 0x84C2
223 #define GL_TEXTURE3_ARB                                 0x84C3
224 #define GL_TEXTURE4_ARB                                 0x84C4
225 #define GL_TEXTURE5_ARB                                 0x84C5
226 #define GL_TEXTURE6_ARB                                 0x84C6
227 #define GL_TEXTURE7_ARB                                 0x84C7
228 #define GL_TEXTURE8_ARB                                 0x84C8
229 #define GL_TEXTURE9_ARB                                 0x84C9
230 #define GL_TEXTURE10_ARB                                0x84CA
231 #define GL_TEXTURE11_ARB                                0x84CB
232 #define GL_TEXTURE12_ARB                                0x84CC
233 #define GL_TEXTURE13_ARB                                0x84CD
234 #define GL_TEXTURE14_ARB                                0x84CE
235 #define GL_TEXTURE15_ARB                                0x84CF
236 #define GL_TEXTURE16_ARB                                0x84D0
237 #define GL_TEXTURE17_ARB                                0x84D1
238 #define GL_TEXTURE18_ARB                                0x84D2
239 #define GL_TEXTURE19_ARB                                0x84D3
240 #define GL_TEXTURE20_ARB                                0x84D4
241 #define GL_TEXTURE21_ARB                                0x84D5
242 #define GL_TEXTURE22_ARB                                0x84D6
243 #define GL_TEXTURE23_ARB                                0x84D7
244 #define GL_TEXTURE24_ARB                                0x84D8
245 #define GL_TEXTURE25_ARB                                0x84D9
246 #define GL_TEXTURE26_ARB                                0x84DA
247 #define GL_TEXTURE27_ARB                                0x84DB
248 #define GL_TEXTURE28_ARB                                0x84DC
249 #define GL_TEXTURE29_ARB                                0x84DD
250 #define GL_TEXTURE30_ARB                                0x84DE
251 #define GL_TEXTURE31_ARB                                0x84DF
252 #endif
253
254 // GL_EXT_compiled_vertex_array
255 extern int gl_supportslockarrays;
256 extern void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count);
257 extern void (GLAPIENTRY *qglUnlockArraysEXT) (void);
258
259 // GL_ARB_texture_env_combine
260 extern int gl_combine_extension;
261 #ifndef GL_COMBINE_ARB
262 #define GL_COMBINE_ARB                                  0x8570
263 #define GL_COMBINE_RGB_ARB                              0x8571
264 #define GL_COMBINE_ALPHA_ARB                    0x8572
265 #define GL_SOURCE0_RGB_ARB                              0x8580
266 #define GL_SOURCE1_RGB_ARB                              0x8581
267 #define GL_SOURCE2_RGB_ARB                              0x8582
268 #define GL_SOURCE0_ALPHA_ARB                    0x8588
269 #define GL_SOURCE1_ALPHA_ARB                    0x8589
270 #define GL_SOURCE2_ALPHA_ARB                    0x858A
271 #define GL_OPERAND0_RGB_ARB                             0x8590
272 #define GL_OPERAND1_RGB_ARB                             0x8591
273 #define GL_OPERAND2_RGB_ARB                             0x8592
274 #define GL_OPERAND0_ALPHA_ARB                   0x8598
275 #define GL_OPERAND1_ALPHA_ARB                   0x8599
276 #define GL_OPERAND2_ALPHA_ARB                   0x859A
277 #define GL_RGB_SCALE_ARB                                0x8573
278 #define GL_ADD_SIGNED_ARB                               0x8574
279 #define GL_INTERPOLATE_ARB                              0x8575
280 #define GL_SUBTRACT_ARB                                 0x84E7
281 #define GL_CONSTANT_ARB                                 0x8576
282 #define GL_PRIMARY_COLOR_ARB                    0x8577
283 #define GL_PREVIOUS_ARB                                 0x8578
284 #endif
285
286 #ifndef GL_MAX_ELEMENTS_VERTICES
287 #define GL_MAX_ELEMENTS_VERTICES                0x80E8
288 #endif
289 #ifndef GL_MAX_ELEMENTS_INDICES
290 #define GL_MAX_ELEMENTS_INDICES                 0x80E9
291 #endif
292
293 extern cvar_t gl_combine;
294
295 extern void (GLAPIENTRY *qglClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
296
297 extern void (GLAPIENTRY *qglClear)(GLbitfield mask);
298
299 //extern void (GLAPIENTRY *qglAlphaFunc)(GLenum func, GLclampf ref);
300 extern void (GLAPIENTRY *qglBlendFunc)(GLenum sfactor, GLenum dfactor);
301 extern void (GLAPIENTRY *qglCullFace)(GLenum mode);
302
303 extern void (GLAPIENTRY *qglDrawBuffer)(GLenum mode);
304 extern void (GLAPIENTRY *qglReadBuffer)(GLenum mode);
305 extern void (GLAPIENTRY *qglEnable)(GLenum cap);
306 extern void (GLAPIENTRY *qglDisable)(GLenum cap);
307 //extern GLboolean GLAPIENTRY *qglIsEnabled)(GLenum cap);
308
309 extern void (GLAPIENTRY *qglEnableClientState)(GLenum cap);
310 extern void (GLAPIENTRY *qglDisableClientState)(GLenum cap);
311
312 extern void (GLAPIENTRY *qglGetBooleanv)(GLenum pname, GLboolean *params);
313 extern void (GLAPIENTRY *qglGetDoublev)(GLenum pname, GLdouble *params);
314 extern void (GLAPIENTRY *qglGetFloatv)(GLenum pname, GLfloat *params);
315 extern void (GLAPIENTRY *qglGetIntegerv)(GLenum pname, GLint *params);
316
317 extern GLenum (GLAPIENTRY *qglGetError)(void);
318 extern const GLubyte* (GLAPIENTRY *qglGetString)(GLenum name);
319 extern void (GLAPIENTRY *qglFinish)(void);
320 extern void (GLAPIENTRY *qglFlush)(void);
321
322 extern void (GLAPIENTRY *qglClearDepth)(GLclampd depth);
323 extern void (GLAPIENTRY *qglDepthFunc)(GLenum func);
324 extern void (GLAPIENTRY *qglDepthMask)(GLboolean flag);
325 extern void (GLAPIENTRY *qglDepthRange)(GLclampd near_val, GLclampd far_val);
326
327 extern void (GLAPIENTRY *qglDrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
328 extern void (GLAPIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
329 extern void (GLAPIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
330 //extern void (GLAPIENTRY *qglNormalPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
331 extern void (GLAPIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
332 extern void (GLAPIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
333 extern void (GLAPIENTRY *qglArrayElement)(GLint i);
334
335 extern void (GLAPIENTRY *qglColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
336 extern void (GLAPIENTRY *qglTexCoord2f)(GLfloat s, GLfloat t);
337 extern void (GLAPIENTRY *qglVertex2f)(GLfloat x, GLfloat y);
338 extern void (GLAPIENTRY *qglVertex3f)(GLfloat x, GLfloat y, GLfloat z);
339 extern void (GLAPIENTRY *qglBegin)(GLenum mode);
340 extern void (GLAPIENTRY *qglEnd)(void);
341
342 extern void (GLAPIENTRY *qglMatrixMode)(GLenum mode);
343 extern void (GLAPIENTRY *qglOrtho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val);
344 extern void (GLAPIENTRY *qglFrustum)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val);
345 extern void (GLAPIENTRY *qglViewport)(GLint x, GLint y, GLsizei width, GLsizei height);
346 //extern void (GLAPIENTRY *qglPushMatrix)(void);
347 //extern void (GLAPIENTRY *qglPopMatrix)(void);
348 extern void (GLAPIENTRY *qglLoadIdentity)(void);
349 extern void (GLAPIENTRY *qglLoadMatrixd)(const GLdouble *m);
350 extern void (GLAPIENTRY *qglLoadMatrixf)(const GLfloat *m);
351 //extern void (GLAPIENTRY *qglMultMatrixd)(const GLdouble *m);
352 //extern void (GLAPIENTRY *qglMultMatrixf)(const GLfloat *m);
353 //extern void (GLAPIENTRY *qglRotated)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
354 extern void (GLAPIENTRY *qglRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
355 //extern void (GLAPIENTRY *qglScaled)(GLdouble x, GLdouble y, GLdouble z);
356 //extern void (GLAPIENTRY *qglScalef)(GLfloat x, GLfloat y, GLfloat z);
357 //extern void (GLAPIENTRY *qglTranslated)(GLdouble x, GLdouble y, GLdouble z);
358 extern void (GLAPIENTRY *qglTranslatef)(GLfloat x, GLfloat y, GLfloat z);
359
360 extern void (GLAPIENTRY *qglReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
361
362 //extern void (GLAPIENTRY *qglStencilFunc)(GLenum func, GLint ref, GLuint mask);
363 //extern void (GLAPIENTRY *qglStencilMask)(GLuint mask);
364 //extern void (GLAPIENTRY *qglStencilOp)(GLenum fail, GLenum zfail, GLenum zpass);
365 //extern void (GLAPIENTRY *qglClearStencil)(GLint s);
366
367 //extern void (GLAPIENTRY *qglTexEnvf)(GLenum target, GLenum pname, GLfloat param);
368 extern void (GLAPIENTRY *qglTexEnvi)(GLenum target, GLenum pname, GLint param);
369
370 //extern void (GLAPIENTRY *qglTexParameterf)(GLenum target, GLenum pname, GLfloat param);
371 extern void (GLAPIENTRY *qglTexParameteri)(GLenum target, GLenum pname, GLint param);
372
373 extern void (GLAPIENTRY *qglBindTexture)(GLenum target, GLuint texture);
374 extern void (GLAPIENTRY *qglTexImage2D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels );
375 extern void (GLAPIENTRY *qglTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
376 extern void (GLAPIENTRY *qglDeleteTextures)(GLsizei n, const GLuint *textures);
377
378 #if WIN32
379 extern int (WINAPI *qwglChoosePixelFormat)(HDC, CONST PIXELFORMATDESCRIPTOR *);
380 extern int (WINAPI *qwglDescribePixelFormat)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
381 //extern int (WINAPI *qwglGetPixelFormat)(HDC);
382 extern BOOL (WINAPI *qwglSetPixelFormat)(HDC, int, CONST PIXELFORMATDESCRIPTOR *);
383 extern BOOL (WINAPI *qwglSwapBuffers)(HDC);
384 extern HGLRC (WINAPI *qwglCreateContext)(HDC);
385 extern BOOL (WINAPI *qwglDeleteContext)(HGLRC);
386 extern PROC (WINAPI *qwglGetProcAddress)(LPCSTR);
387 extern BOOL (WINAPI *qwglMakeCurrent)(HDC, HGLRC);
388 extern BOOL (WINAPI *qwglSwapIntervalEXT)(int interval);
389 #endif
390
391 #define DEBUGGL
392
393 #ifdef DEBUGGL
394 #define CHECKGLERROR if ((errornumber = qglGetError())) GL_PrintError(errornumber, __FILE__, __LINE__);
395 extern int errornumber;
396 void GL_PrintError(int errornumber, char *filename, int linenumber);
397 #else
398 #define CHECKGLERROR
399 #endif
400
401 #endif
402