From 0e6681a069080c0f8159e195e6b057cb6fd610f0 Mon Sep 17 00:00:00 2001 From: Ragnvald Maartmann-Moe IV Date: Wed, 28 Jan 2004 02:49:57 +0000 Subject: [PATCH] Add QFGL_WANT, and ability to handle non-required extensions. --- include/QF/GL/funcs.h | 2 ++ include/QF/GL/qf_funcs_list.h | 11 ++++++++++- include/r_cvar.h | 1 + libs/video/targets/qfgl_ext.c | 10 ++++++++-- libs/video/targets/vid_common_gl.c | 8 ++++---- tools/3dfx_stub/gl_stub.c | 11 ++++++++++- tools/gl_stub/gl_stub.c | 10 ++++++++++ tools/gl_stub/glx_funcs_list.h | 9 +++++++++ 8 files changed, 54 insertions(+), 8 deletions(-) diff --git a/include/QF/GL/funcs.h b/include/QF/GL/funcs.h index 5bc1c7da0..474c2b691 100644 --- a/include/QF/GL/funcs.h +++ b/include/QF/GL/funcs.h @@ -37,9 +37,11 @@ # include #endif +#define QFGL_WANT(ret, name, args) extern ret (GLAPIENTRY * qf##name) args; #define QFGL_NEED(ret, name, args) extern ret (GLAPIENTRY * qf##name) args; #include "QF/GL/qf_funcs_list.h" #undef QFGL_NEED +#undef QFGL_WANT extern void *libgl_handle; diff --git a/include/QF/GL/qf_funcs_list.h b/include/QF/GL/qf_funcs_list.h index c46922748..b4ede17f8 100644 --- a/include/QF/GL/qf_funcs_list.h +++ b/include/QF/GL/qf_funcs_list.h @@ -31,6 +31,11 @@ #define UNDEF_QFGL_DONT_NEED #endif +#ifndef QFGL_WANT +#define QFGL_WANT(ret, func, params) +#define UNDEF_QFGL_WANT +#endif + #ifndef QFGL_NEED #define QFGL_NEED(ret, func, params) #define UNDEF_QFGL_NEED @@ -412,12 +417,16 @@ QFGL_NEED (void, glVertexPointer, (GLint size, GLenum type, GLsizei stride, cons QFGL_NEED (void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)) // ATI Extensions -QFGL_NEED (void, glPNTrianglesiATI, (GLenum pname, GLint param)) +QFGL_WANT (void, glPNTrianglesiATI, (GLenum pname, GLint param)) #ifdef UNDEF_QFGL_DONT_NEED #undef QFGL_DONT_NEED #endif +#ifdef UNDEF_QFGL_WANT +#undef QFGL_WANT +#endif + #ifdef UNDEF_QFGL_NEED #undef QFGL_DONT_NEED #endif diff --git a/include/r_cvar.h b/include/r_cvar.h index 4c011484f..0c9c2e661 100644 --- a/include/r_cvar.h +++ b/include/r_cvar.h @@ -36,6 +36,7 @@ extern struct cvar_s *gl_sky_clip; extern struct cvar_s *gl_sky_debug; extern struct cvar_s *gl_sky_divide; extern struct cvar_s *gl_sky_multipass; +extern struct cvar_s *gl_tessellate; extern struct cvar_s *gl_texsort; extern struct cvar_s *gl_triplebuffer; diff --git a/libs/video/targets/qfgl_ext.c b/libs/video/targets/qfgl_ext.c index eef6f3118..60c8f42db 100644 --- a/libs/video/targets/qfgl_ext.c +++ b/libs/video/targets/qfgl_ext.c @@ -94,10 +94,13 @@ QFGL_ProcAddress (void *handle, const char *name, qboolean crit) } // First we need to get all the function pointers declared. -#define QFGL_NEED(ret, name, args) \ +#define QFGL_WANT(ret, name, args) \ + ret (GLAPIENTRY * qf##name) args; +#define QFGL_NEED(ret, name, args) \ ret (GLAPIENTRY * qf##name) args; #include "QF/GL/qf_funcs_list.h" #undef QFGL_NEED +#undef QFGL_WANT void *libgl_handle; // Then we need to open the libGL and set all the symbols. @@ -106,10 +109,13 @@ GLF_Init (void) { libgl_handle = QFGL_LoadLibrary (); -#define QFGL_NEED(ret, name, args) \ +#define QFGL_WANT(ret, name, args) \ + qf##name = QFGL_ProcAddress (libgl_handle, #name, false); +#define QFGL_NEED(ret, name, args) \ qf##name = QFGL_ProcAddress (libgl_handle, #name, true); #include "QF/GL/qf_funcs_list.h" #undef QFGL_NEED +#undef QFGL_WANT return true; } diff --git a/libs/video/targets/vid_common_gl.c b/libs/video/targets/vid_common_gl.c index 31bfe9a1b..9a4a12f39 100644 --- a/libs/video/targets/vid_common_gl.c +++ b/libs/video/targets/vid_common_gl.c @@ -165,10 +165,10 @@ GL_Common_Init_Cvars (void) gl_screenshot_byte_swap_f, "Swap the bytes for gl " "screenshots. Needed if you get screenshots with red and " "blue swapped."); - gl_tessellate = Cvar_Get ("gl_tessellate", "0", CVAR_NONE, gl_tessellate_f, - nva ("Specifies tessellation level from 0 to " - "%i. Quadruples the triangle count at each " - "tessellation level.", tess_max)); + gl_tessellate = + Cvar_Get ("gl_tessellate", "0", CVAR_NONE, gl_tessellate_f, + nva ("Specifies tessellation level from 0 to %i. Higher " + "tessellation level means more triangles.", tess_max)); gl_vaelements_max = Cvar_Get ("gl_vaelements_max", "0", CVAR_ROM, NULL, "Limit the vertex array size for buggy " "drivers. 0 (default) uses driver provided " diff --git a/tools/3dfx_stub/gl_stub.c b/tools/3dfx_stub/gl_stub.c index 575d166df..20984283a 100644 --- a/tools/3dfx_stub/gl_stub.c +++ b/tools/3dfx_stub/gl_stub.c @@ -40,21 +40,27 @@ #define QFGL_DONT_NEED(ret, func, params) QFGL_NEED(ret, func, params) +#undef QFGL_WANT #undef QFGL_NEED - +#define QFGL_WANT(ret, name, args) \ +ret GLAPIENTRY norm_##name args; #define QFGL_NEED(ret, name, args) \ ret GLAPIENTRY norm_##name args; #include "QF/GL/qf_funcs_list.h" #undef QFGL_NEED +#undef QFGL_WANT fxMesaContext norm_fxMesaCreateContext (GLuint win, GrScreenResolution_t res, GrScreenRefresh_t ref, const GLint attribList[]); void norm_fxMesaMakeCurrent(fxMesaContext fxMesa); void norm_fxMesaDestroyContext(fxMesaContext fxMesa); void norm_fxMesaSwapBuffers(void); +#define QFGL_WANT(ret, name, args) \ +ret GLAPIENTRY trace_##name args; #define QFGL_NEED(ret, name, args) \ ret GLAPIENTRY trace_##name args; #include "QF/GL/qf_funcs_list.h" #undef QFGL_NEED +#undef QFGL_WANT fxMesaContext trace_fxMesaCreateContext (GLuint win, GrScreenResolution_t res, GrScreenRefresh_t ref, const GLint attribList[]); void trace_fxMesaMakeCurrent(fxMesaContext fxMesa); void trace_fxMesaDestroyContext(fxMesaContext fxMesa); @@ -67,10 +73,13 @@ typedef struct { } gl_stub_t; static gl_stub_t gl_stub_funcs[] = { +#define QFGL_WANT(ret, name, args) \ + {#name, norm_##name, trace_##name}, #define QFGL_NEED(ret, name, args) \ {#name, norm_##name, trace_##name}, #include "QF/GL/qf_funcs_list.h" #undef QFGL_NEED +#undef QFGL_WANT {"fxMesaCreateContext", norm_fxMesaCreateContext, trace_fxMesaCreateContext}, {"fxMesaMakeCurrent", norm_fxMesaMakeCurrent, trace_fxMesaMakeCurrent}, {"fxMesaDestroyContext", norm_fxMesaDestroyContext, trace_fxMesaDestroyContext}, diff --git a/tools/gl_stub/gl_stub.c b/tools/gl_stub/gl_stub.c index 743e0fa29..a94eb645c 100644 --- a/tools/gl_stub/gl_stub.c +++ b/tools/gl_stub/gl_stub.c @@ -20,17 +20,24 @@ typedef struct __GLXcontextRec *GLXContext; #define QFGL_DONT_NEED(ret, func, params) QFGL_NEED(ret, func, params) +#undef QFGL_WANT #undef QFGL_NEED +#define QFGL_WANT(ret, name, args) \ +ret GLAPIENTRY norm_##name args; #define QFGL_NEED(ret, name, args) \ ret GLAPIENTRY norm_##name args; #include "QF/GL/qf_funcs_list.h" #undef QFGL_NEED +#undef QFGL_WANT +#define QFGL_WANT(ret, name, args) \ +ret GLAPIENTRY trace_##name args; #define QFGL_NEED(ret, name, args) \ ret GLAPIENTRY trace_##name args; #include "QF/GL/qf_funcs_list.h" #undef QFGL_NEED +#undef QFGL_WANT typedef struct { const char *name; @@ -41,10 +48,13 @@ typedef struct { static int trace; static gl_stub_t gl_stub_funcs[] = { +#define QFGL_WANT(ret, name, args) \ + {#name, norm_##name, trace_##name}, #define QFGL_NEED(ret, name, args) \ {#name, norm_##name, trace_##name}, #include "QF/GL/qf_funcs_list.h" #undef QFGL_NEED +#undef QFGL_WANT }; #define NUM_FUNCS (sizeof (gl_stub_funcs) / sizeof (gl_stub_funcs[0])) diff --git a/tools/gl_stub/glx_funcs_list.h b/tools/gl_stub/glx_funcs_list.h index f6494e094..1ba9cde46 100644 --- a/tools/gl_stub/glx_funcs_list.h +++ b/tools/gl_stub/glx_funcs_list.h @@ -31,6 +31,11 @@ #define UNDEF_QFGL_DONT_NEED #endif +#ifndef QFGL_WANT +#define QFGL_WANT(ret, func, params) +#define UNDEF_QFGL_WANT +#endif + #ifndef QFGL_NEED #define QFGL_NEED(ret, func, params) #define UNDEF_QFGL_NEED @@ -45,6 +50,10 @@ QFGL_NEED (void, glXMakeCurrent, (Display *dpy, GLXDrawable drawable, GLXContext #undef QFGL_DONT_NEED #endif +#ifdef UNDEF_QFGL_WANT +#undef QFGL_WANT +#endif + #ifdef UNDEF_QFGL_NEED #undef QFGL_DONT_NEED #endif