Quake II RTX doxygen  1.0 dev
dynamic.c
Go to the documentation of this file.
1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (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. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18 
19 #include "shared/shared.h"
20 #include "common/common.h"
21 #include "client/video.h"
22 #include "dynamic.h"
23 
24 // ==========================================================
25 
26 #define QGL(x) qgl##x##_t qgl##x
32 #undef QGL
33 
35 
36 // ==========================================================
37 
38 #ifdef _DEBUG
39 
40 static FILE *log_fp;
41 
42 #define QGL(x) static qgl##x##_t dll##x
48 #undef QGL
49 
50 #define SIG(x) fprintf(log_fp, "%s\n", x)
51 #define SIGf(...) fprintf(log_fp, __VA_ARGS__)
52 
53 static const char *enumToString(GLenum num)
54 {
55 #define E(x) case x: return #x;
56  switch (num) {
57 /* Data types */
58  E(GL_UNSIGNED_BYTE)
59  E(GL_UNSIGNED_SHORT)
60  E(GL_UNSIGNED_INT)
61  E(GL_FLOAT)
62 
63 /* Primitives */
64  E(GL_LINES)
65  E(GL_LINE_STRIP)
66  E(GL_TRIANGLES)
67  E(GL_TRIANGLE_STRIP)
68 
69 /* Vertex Arrays */
70  E(GL_VERTEX_ARRAY)
71  E(GL_COLOR_ARRAY)
72  E(GL_TEXTURE_COORD_ARRAY)
73 
74 /* Matrix Mode */
75  E(GL_MODELVIEW)
76  E(GL_PROJECTION)
77  E(GL_TEXTURE)
78 
79 /* Polygons */
80  E(GL_LINE)
81  E(GL_FILL)
82  E(GL_CW)
83  E(GL_CCW)
84  E(GL_FRONT)
85  E(GL_BACK)
86  E(GL_CULL_FACE)
87  E(GL_POLYGON_OFFSET_FILL)
88 
89 /* Depth buffer */
90  E(GL_LEQUAL)
91  E(GL_GREATER)
92  E(GL_DEPTH_TEST)
93 
94 /* Lighting */
95  E(GL_FRONT_AND_BACK)
96  E(GL_FLAT)
97  E(GL_SMOOTH)
98 
99 /* Alpha testing */
100  E(GL_ALPHA_TEST)
101 
102 /* Blending */
103  E(GL_BLEND)
104  E(GL_SRC_ALPHA)
105  E(GL_ONE_MINUS_SRC_ALPHA)
106  E(GL_DST_COLOR)
107 
108 /* Stencil */
109  E(GL_STENCIL_TEST)
110  E(GL_REPLACE)
111 
112 /* Scissor box */
113  E(GL_SCISSOR_TEST)
114 
115 /* Texture mapping */
116  E(GL_TEXTURE_ENV)
117  E(GL_TEXTURE_ENV_MODE)
118  E(GL_TEXTURE_2D)
119  E(GL_TEXTURE_WRAP_S)
120  E(GL_TEXTURE_WRAP_T)
121  E(GL_TEXTURE_MAG_FILTER)
122  E(GL_TEXTURE_MIN_FILTER)
123  E(GL_MODULATE)
124 
125 /* GL_ARB_fragment_program */
126  E(GL_FRAGMENT_PROGRAM_ARB)
127 
128 /* GL_EXT_texture_filter_anisotropic */
129  E(GL_TEXTURE_MAX_ANISOTROPY_EXT)
130  }
131 #undef E
132  return va("%#x", num);
133 }
134 
135 static void APIENTRY logAlphaFunc(GLenum func, GLclampf ref)
136 {
137  SIGf("%s( %s, %f )\n", "glAlphaFunc", enumToString(func), ref);
138  dllAlphaFunc(func, ref);
139 }
140 
141 static void APIENTRY logBindTexture(GLenum target, GLuint texture)
142 {
143  SIGf("%s( %s, %u )\n", "glBindTexture", enumToString(target), texture);
144  dllBindTexture(target, texture);
145 }
146 
147 static void APIENTRY logBlendFunc(GLenum sfactor, GLenum dfactor)
148 {
149  SIGf("%s( %s, %s )\n", "glBlendFunc", enumToString(sfactor), enumToString(dfactor));
150  dllBlendFunc(sfactor, dfactor);
151 }
152 
153 static void APIENTRY logClear(GLbitfield mask)
154 {
155  SIGf("%s( %#x )\n", "glClear", mask);
156  dllClear(mask);
157 }
158 
159 static void APIENTRY logClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
160 {
161  SIG("glClearColor");
162  dllClearColor(red, green, blue, alpha);
163 }
164 
165 static void APIENTRY logClearDepth(GLclampd depth)
166 {
167  SIG("glClearDepth");
168  dllClearDepth(depth);
169 }
170 
171 static void APIENTRY logClearStencil(GLint s)
172 {
173  SIG("glClearStencil");
174  dllClearStencil(s);
175 }
176 
177 static void APIENTRY logColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
178 {
179  SIGf("%s( %f, %f, %f, %f )\n", "glColor4f", red, green, blue, alpha);
180  dllColor4f(red, green, blue, alpha);
181 }
182 
183 static void APIENTRY logColor4fv(const GLfloat *v)
184 {
185  SIGf("%s( %f, %f, %f, %f )\n", "glColor4fv", v[0], v[1], v[2], v[3]);
186  dllColor4fv(v);
187 }
188 
189 static void APIENTRY logColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
190 {
191  SIG("glColorMask");
192  dllColorMask(red, green, blue, alpha);
193 }
194 
195 static void APIENTRY logColorPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
196 {
197  SIGf("%s( %d, %s, %d, %p )\n", "glColorPointer", size, enumToString(type), stride, pointer);
198  dllColorPointer(size, type, stride, pointer);
199 }
200 
201 static void APIENTRY logCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
202 {
203  SIG("glCopyTexImage2D");
204  dllCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
205 }
206 
207 static void APIENTRY logCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
208 {
209  SIG("glCopyTexSubImage2D");
210  dllCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
211 }
212 
213 static void APIENTRY logCullFace(GLenum mode)
214 {
215  SIGf("%s( %s )\n", "glCullFace", enumToString(mode));
216  dllCullFace(mode);
217 }
218 
219 static void APIENTRY logDeleteTextures(GLsizei n, const GLuint *textures)
220 {
221  SIGf("%s( %d, %p )\n", "glDeleteTextures", n, textures);
222  dllDeleteTextures(n, textures);
223 }
224 
225 static void APIENTRY logDepthFunc(GLenum func)
226 {
227  SIGf("%s( %s )\n", "glDepthFunc", enumToString(func));
228  dllDepthFunc(func);
229 }
230 
231 static void APIENTRY logDepthMask(GLboolean flag)
232 {
233  SIGf("%s( %s )\n", "glDepthMask", flag ? "GL_TRUE" : "GL_FALSE");
234  dllDepthMask(flag);
235 }
236 
237 static void APIENTRY logDepthRange(GLclampd zNear, GLclampd zFar)
238 {
239  SIGf("%s( %f, %f )\n", "glDepthRange", zNear, zFar);
240  dllDepthRange(zNear, zFar);
241 }
242 
243 static void APIENTRY logDisable(GLenum cap)
244 {
245  SIGf("%s( %s )\n", "glDisable", enumToString(cap));
246  dllDisable(cap);
247 }
248 
249 static void APIENTRY logDisableClientState(GLenum array)
250 {
251  SIGf("%s( %s )\n", "glDisableClientState", enumToString(array));
252  dllDisableClientState(array);
253 }
254 
255 static void APIENTRY logDrawArrays(GLenum mode, GLint first, GLsizei count)
256 {
257  SIGf("%s( %s, %u, %u )\n", "glDrawArrays", enumToString(mode), first, count);
258  dllDrawArrays(mode, first, count);
259 }
260 
261 static void APIENTRY logDrawElements(GLenum mode, GLsizei count, GLenum type, const void *indices)
262 {
263  SIGf("%s( %s, %u, %s, %p )\n", "glDrawElements", enumToString(mode), count, enumToString(type), indices);
264  dllDrawElements(mode, count, type, indices);
265 }
266 
267 static void APIENTRY logEnable(GLenum cap)
268 {
269  SIGf("%s( %s )\n", "glEnable", enumToString(cap));
270  dllEnable(cap);
271 }
272 
273 static void APIENTRY logEnableClientState(GLenum array)
274 {
275  SIGf("%s( %s )\n", "glEnableClientState", enumToString(array));
276  dllEnableClientState(array);
277 }
278 
279 static void APIENTRY logFinish(void)
280 {
281  SIG("glFinish");
282  dllFinish();
283 }
284 
285 static void APIENTRY logFlush(void)
286 {
287  SIG("glFlush");
288  dllFlush();
289 }
290 
291 static void APIENTRY logFogf(GLenum pname, GLfloat param)
292 {
293  SIG("glFogf");
294  dllFogf(pname, param);
295 }
296 
297 static void APIENTRY logFogfv(GLenum pname, const GLfloat *params)
298 {
299  SIG("glFogfv");
300  dllFogfv(pname, params);
301 }
302 
303 static void APIENTRY logFrontFace(GLenum mode)
304 {
305  SIGf("%s( %s )\n", "glFrontFace", enumToString(mode));
306  dllFrontFace(mode);
307 }
308 
309 static void APIENTRY logFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
310 {
311  SIG("glFrustum");
312  dllFrustum(left, right, bottom, top, zNear, zFar);
313 }
314 
315 static void APIENTRY logGenTextures(GLsizei n, GLuint *textures)
316 {
317  SIGf("%s( %d, %p )\n", "glGenTextures", n, textures);
318  dllGenTextures(n, textures);
319 }
320 
321 static GLenum APIENTRY logGetError(void)
322 {
323  SIG("glGetError");
324  return dllGetError();
325 }
326 
327 static void APIENTRY logGetFloatv(GLenum pname, GLfloat *params)
328 {
329  SIG("glGetFloatv");
330  dllGetFloatv(pname, params);
331 }
332 
333 static void APIENTRY logGetIntegerv(GLenum pname, GLint *params)
334 {
335  SIG("glGetIntegerv");
336  dllGetIntegerv(pname, params);
337 }
338 
339 static const GLubyte * APIENTRY logGetString(GLenum name)
340 {
341  SIG("glGetString");
342  return dllGetString(name);
343 }
344 
345 static void APIENTRY logHint(GLenum target, GLenum mode)
346 {
347  SIGf("%s( %#x, %#x )\n", "glHint", target, mode);
348  dllHint(target, mode);
349 }
350 
351 static GLboolean APIENTRY logIsEnabled(GLenum cap)
352 {
353  SIG("glIsEnabled");
354  return dllIsEnabled(cap);
355 }
356 
357 static GLboolean APIENTRY logIsTexture(GLuint texture)
358 {
359  SIG("glIsTexture");
360  return dllIsTexture(texture);
361 }
362 
363 static void APIENTRY logLightModelf(GLenum pname, GLfloat param)
364 {
365  SIG("glLightModelf");
366  dllLightModelf(pname, param);
367 }
368 
369 static void APIENTRY logLightModelfv(GLenum pname, const GLfloat *params)
370 {
371  SIG("glLightModelfv");
372  dllLightModelfv(pname, params);
373 }
374 
375 static void APIENTRY logLightf(GLenum light, GLenum pname, GLfloat param)
376 {
377  SIG("glLightf");
378  dllLightf(light, pname, param);
379 }
380 
381 static void APIENTRY logLightfv(GLenum light, GLenum pname, const GLfloat *params)
382 {
383  SIG("glLightfv");
384  dllLightfv(light, pname, params);
385 }
386 
387 static void APIENTRY logLineWidth(GLfloat width)
388 {
389  SIG("glLineWidth");
390  dllLineWidth(width);
391 }
392 
393 static void APIENTRY logLoadIdentity(void)
394 {
395  SIG("glLoadIdentity");
396  dllLoadIdentity();
397 }
398 
399 static void APIENTRY logLoadMatrixf(const GLfloat *m)
400 {
401  SIGf("glLoadMatrixf( %p )\n", m);
402  dllLoadMatrixf(m);
403 }
404 
405 static void APIENTRY logLogicOp(GLenum opcode)
406 {
407  SIG("glLogicOp");
408  dllLogicOp(opcode);
409 }
410 
411 static void APIENTRY logMaterialf(GLenum face, GLenum pname, GLfloat param)
412 {
413  SIG("glMaterialf");
414  dllMaterialf(face, pname, param);
415 }
416 
417 static void APIENTRY logMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
418 {
419  SIG("glMaterialfv");
420  dllMaterialfv(face, pname, params);
421 }
422 
423 static void APIENTRY logMatrixMode(GLenum mode)
424 {
425  SIGf("%s( %s )\n", "glMatrixMode", enumToString(mode));
426  dllMatrixMode(mode);
427 }
428 
429 static void APIENTRY logMultMatrixf(const GLfloat *m)
430 {
431  SIG("glMultMatrixf");
432  dllMultMatrixf(m);
433 }
434 
435 static void APIENTRY logNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
436 {
437  SIG("glNormal3f");
438  dllNormal3f(nx, ny, nz);
439 }
440 
441 static void APIENTRY logNormal3fv(const GLfloat *v)
442 {
443  SIG("glNormal3fv");
444  dllNormal3fv(v);
445 }
446 
447 static void APIENTRY logNormalPointer(GLenum type, GLsizei stride, const void *pointer)
448 {
449  SIG("glNormalPointer");
450  dllNormalPointer(type, stride, pointer);
451 }
452 
453 static void APIENTRY logOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
454 {
455  SIG("glOrtho");
456  dllOrtho(left, right, bottom, top, zNear, zFar);
457 }
458 
459 static void APIENTRY logPixelStorei(GLenum pname, GLint param)
460 {
461  SIG("glPixelStorei");
462  dllPixelStorei(pname, param);
463 }
464 
465 static void APIENTRY logPointSize(GLfloat size)
466 {
467  SIG("glPointSize");
468  dllPointSize(size);
469 }
470 
471 static void APIENTRY logPolygonMode(GLenum face, GLenum mode)
472 {
473  SIGf("%s( %s, %s )\n", "glPolygonMode", enumToString(face), enumToString(mode));
474  dllPolygonMode(face, mode);
475 }
476 
477 static void APIENTRY logPolygonOffset(GLfloat factor, GLfloat units)
478 {
479  SIGf("%s( %f, %f )\n", "glPolygonOffset", factor, units);
480  dllPolygonOffset(factor, units);
481 }
482 
483 static void APIENTRY logPopMatrix(void)
484 {
485  SIG("glPopMatrix");
486  dllPopMatrix();
487 }
488 
489 static void APIENTRY logPushMatrix(void)
490 {
491  SIG("glPushMatrix");
492  dllPushMatrix();
493 }
494 
495 static void APIENTRY logReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels)
496 {
497  SIG("glReadPixels");
498  dllReadPixels(x, y, width, height, format, type, pixels);
499 }
500 
501 static void APIENTRY logRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
502 {
503  SIG("glRotatef");
504  dllRotatef(angle, x, y, z);
505 }
506 
507 static void APIENTRY logScalef(GLfloat x, GLfloat y, GLfloat z)
508 {
509  SIG("glScalef");
510  dllScalef(x, y, z);
511 }
512 
513 static void APIENTRY logScissor(GLint x, GLint y, GLsizei width, GLsizei height)
514 {
515  SIGf("%s( %d, %d, %d, %d )\n", "glScissor", x, y, width, height);
516  dllScissor(x, y, width, height);
517 }
518 
519 static void APIENTRY logShadeModel(GLenum mode)
520 {
521  SIGf("%s( %s )\n", "glShadeModel", enumToString(mode));
522  dllShadeModel(mode);
523 }
524 
525 static void APIENTRY logStencilFunc(GLenum func, GLint ref, GLuint mask)
526 {
527  SIG("glStencilFunc");
528  dllStencilFunc(func, ref, mask);
529 }
530 
531 static void APIENTRY logStencilMask(GLuint mask)
532 {
533  SIG("glStencilMask");
534  dllStencilMask(mask);
535 }
536 
537 static void APIENTRY logStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
538 {
539  SIG("glStencilOp");
540  dllStencilOp(fail, zfail, zpass);
541 }
542 
543 static void APIENTRY logTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
544 {
545  SIGf("%s( %d, %s, %d, %p )\n", "glTexCoordPointer", size, enumToString(type), stride, pointer);
546  dllTexCoordPointer(size, type, stride, pointer);
547 }
548 
549 static void APIENTRY logTexEnvf(GLenum target, GLenum pname, GLfloat param)
550 {
551  SIGf("%s( %s, %s, %s )\n", "glTexEnvf", enumToString(target), enumToString(pname), enumToString(param));
552  dllTexEnvf(target, pname, param);
553 }
554 
555 static void APIENTRY logTexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
556 {
557  SIG("glTexEnvfv");
558  dllTexEnvfv(target, pname, params);
559 }
560 
561 static void APIENTRY logTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels)
562 {
563  SIG("glTexImage2D");
564  dllTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
565 }
566 
567 static void APIENTRY logTexParameterf(GLenum target, GLenum pname, GLfloat param)
568 {
569  SIGf("%s( %s, %s, %f )\n", "glTexParameterf", enumToString(target), enumToString(pname), param);
570  dllTexParameterf(target, pname, param);
571 }
572 
573 static void APIENTRY logTexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
574 {
575  SIG("glTexParameterfv");
576  dllTexParameterfv(target, pname, params);
577 }
578 
579 static void APIENTRY logTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels)
580 {
581  SIG("glTexSubImage2D");
582  dllTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
583 }
584 
585 static void APIENTRY logTranslatef(GLfloat x, GLfloat y, GLfloat z)
586 {
587  SIG("glTranslatef");
588  dllTranslatef(x, y, z);
589 }
590 
591 static void APIENTRY logVertexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
592 {
593  SIGf("%s( %d, %s, %d, %p )\n", "glVertexPointer", size, enumToString(type), stride, pointer);
594  dllVertexPointer(size, type, stride, pointer);
595 }
596 
597 static void APIENTRY logViewport(GLint x, GLint y, GLsizei width, GLsizei height)
598 {
599  SIGf("%s( %d, %d, %d, %d )\n", "glViewport", x, y, width, height);
600  dllViewport(x, y, width, height);
601 }
602 
603 static void APIENTRY logActiveTextureARB(GLenum texture)
604 {
605  SIGf("%s( GL_TEXTURE%d )\n", "glActiveTextureARB", texture - GL_TEXTURE0);
606  dllActiveTextureARB(texture);
607 }
608 
609 static void APIENTRY logClientActiveTextureARB(GLenum texture)
610 {
611  SIGf("%s( GL_TEXTURE%d )\n", "glClientActiveTextureARB", texture - GL_TEXTURE0);
612  dllClientActiveTextureARB(texture);
613 }
614 
615 static void APIENTRY logLockArraysEXT(GLint first, GLsizei count)
616 {
617  SIGf("%s( %u, %u )\n", "glLockArraysEXT", first, count);
618  dllLockArraysEXT(first, count);
619 }
620 
621 static void APIENTRY logUnlockArraysEXT(void)
622 {
623  SIG("glUnlockArraysEXT");
624  dllUnlockArraysEXT();
625 }
626 
627 #endif // _DEBUG
628 
629 // ==========================================================
630 
631 void QGL_Shutdown(void)
632 {
633 #ifdef _DEBUG
634 #define QGL(x) qgl##x = dll##x = NULL
635 #else
636 #define QGL(x) qgl##x = NULL
637 #endif
639 
641 }
642 
643 void QGL_ShutdownExtensions(unsigned mask)
644 {
645  if (mask & QGL_ARB_fragment_program) {
647  }
648 
649  if (mask & QGL_ARB_multitexture) {
651  }
652 
653  if (mask & QGL_ARB_vertex_buffer_object) {
655  }
656 
657  if (mask & QGL_EXT_compiled_vertex_array) {
659  }
660 
661  if (mask & QGL_3_0_core_functions) {
662  qglGenerateMipmap = NULL;
663  }
664 #undef QGL
665 }
666 
667 #define GCA(x) VID_GetCoreAddr("gl"#x)
668 #define GPA(x) VID_GetProcAddr("gl"#x)
669 
670 qboolean QGL_Init(void)
671 {
672 #ifdef _DEBUG
673 #define QGL(x) if ((qgl##x = dll##x = GCA(x)) == NULL) return qfalse;
674 #else
675 #define QGL(x) if ((qgl##x = GCA(x)) == NULL) return qfalse;
676 #endif
678 #undef QGL
679 
680  return qtrue;
681 }
682 
683 void QGL_InitExtensions(unsigned mask)
684 {
685 #ifdef _DEBUG
686 #define QGL(x) qgl##x = dll##x = GPA(x)
687 #else
688 #define QGL(x) qgl##x = GPA(x)
689 #endif
690  if (mask & QGL_ARB_fragment_program) {
692  }
693 
694  if (mask & QGL_ARB_multitexture) {
696  }
697 
698  if (mask & QGL_ARB_vertex_buffer_object) {
700  }
701 
702  if (mask & QGL_EXT_compiled_vertex_array) {
704  }
705 
706  if (mask & QGL_3_0_core_functions) {
707  qglGenerateMipmap = GPA(GenerateMipmap);
708  }
709 #undef QGL
710 }
711 
712 unsigned QGL_ParseExtensionString(const char *s)
713 {
714  // must match defines in dynamic.h!
715  static const char *const extnames[] = {
716  "GL_ARB_fragment_program",
717  "GL_ARB_multitexture",
718  "GL_ARB_vertex_buffer_object",
719  "GL_EXT_compiled_vertex_array",
720  "GL_EXT_texture_filter_anisotropic",
721  NULL
722  };
723 
724  return Com_ParseExtensionString(s, extnames);
725 }
726 
727 #ifdef _DEBUG
728 
729 void QGL_EnableLogging(unsigned mask)
730 {
731  if (!log_fp) {
732  extern char fs_gamedir[];
733  struct tm *newtime;
734  time_t aclock;
735  char buffer[MAX_OSPATH];
736  size_t len;
737 
738  time(&aclock);
739 
740  len = Q_snprintf(buffer, sizeof(buffer), "%s/qgl.log", fs_gamedir);
741  if (len >= sizeof(buffer)) {
742  return;
743  }
744 
745  log_fp = fopen(buffer, "w");
746  if (!log_fp) {
747  return;
748  }
749 
750  newtime = localtime(&aclock);
751  fprintf(log_fp, "%s\n", asctime(newtime));
752  }
753 
754 #define QGL(x) qgl##x = log##x
756 
757  if (mask & QGL_ARB_fragment_program) {
758  }
759 
760  if (mask & QGL_ARB_multitexture) {
762  }
763 
764  if (mask & QGL_ARB_vertex_buffer_object) {
765  }
766 
767  if (mask & QGL_EXT_compiled_vertex_array) {
769  }
770 #undef QGL
771 }
772 
773 void QGL_DisableLogging(unsigned mask)
774 {
775  if (log_fp) {
776  fclose(log_fp);
777  log_fp = NULL;
778  }
779 
780 #define QGL(x) qgl##x = dll##x
782 
783  if (mask & QGL_ARB_fragment_program) {
785  }
786 
787  if (mask & QGL_ARB_multitexture) {
789  }
790 
791  if (mask & QGL_ARB_vertex_buffer_object) {
793  }
794 
795  if (mask & QGL_EXT_compiled_vertex_array) {
797  }
798 #undef QGL
799 }
800 
801 void QGL_LogComment(const char *fmt, ...)
802 {
803  va_list ap;
804 
805  if (log_fp) {
806  va_start(ap, fmt);
807  vfprintf(log_fp, fmt, ap);
808  va_end(ap);
809  }
810 }
811 
812 #endif // _DEBUG
813 
QGL_Shutdown
void QGL_Shutdown(void)
Definition: dynamic.c:631
QGL_ARB_fragment_program_IMP
#define QGL_ARB_fragment_program_IMP
Definition: dynamic.h:118
QGL_3_0_core_functions
#define QGL_3_0_core_functions
Definition: dynamic.h:161
GPA
#define GPA(x)
Definition: dynamic.c:668
dynamic.h
height
static int height
Definition: physical_sky.c:39
Q_snprintf
size_t Q_snprintf(char *dest, size_t size, const char *fmt,...)
Definition: shared.c:846
QGL_EXT_compiled_vertex_array_IMP
#define QGL_EXT_compiled_vertex_array_IMP
Definition: dynamic.h:151
QGL_ARB_multitexture_IMP
#define QGL_ARB_multitexture_IMP
Definition: dynamic.h:132
E
#define E(name)
Definition: g_save.c:50
qglGenerateMipmap
QGL_core_IMP QGL_ARB_fragment_program_IMP QGL_ARB_multitexture_IMP QGL_ARB_vertex_buffer_object_IMP QGL_EXT_compiled_vertex_array_IMP qglGenerateMipmap_t qglGenerateMipmap
Definition: dynamic.c:34
QGL_Init
qboolean QGL_Init(void)
Definition: dynamic.c:670
qglGenerateMipmap_t
void(APIENTRY * qglGenerateMipmap_t)(GLenum target)
Definition: dynamic.h:246
width
static int width
Definition: physical_sky.c:38
QGL_ARB_fragment_program
#define QGL_ARB_fragment_program
Definition: dynamic.h:155
QGL_ARB_vertex_buffer_object_IMP
#define QGL_ARB_vertex_buffer_object_IMP
Definition: dynamic.h:137
va
char * va(const char *format,...)
Definition: shared.c:429
m
static struct mdfour * m
Definition: mdfour.c:32
QGL_ShutdownExtensions
void QGL_ShutdownExtensions(unsigned mask)
Definition: dynamic.c:643
QGL_core_IMP
#define QGL_core_IMP
Definition: dynamic.h:37
APIENTRY
#define APIENTRY
Definition: dynamic.h:32
QGL_ARB_vertex_buffer_object
#define QGL_ARB_vertex_buffer_object
Definition: dynamic.h:157
right
static vec3_t right
Definition: p_view.c:27
QGL_InitExtensions
void QGL_InitExtensions(unsigned mask)
Definition: dynamic.c:683
level
level_locals_t level
Definition: g_main.c:22
QGL_ARB_multitexture
#define QGL_ARB_multitexture
Definition: dynamic.h:156
QGL_ParseExtensionString
unsigned QGL_ParseExtensionString(const char *s)
Definition: dynamic.c:712
fs_gamedir
char fs_gamedir[MAX_OSPATH]
Definition: files.c:171
QGL_EXT_compiled_vertex_array
#define QGL_EXT_compiled_vertex_array
Definition: dynamic.h:158