Add QFGL_WANT, and ability to handle non-required extensions.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2004-01-28 02:49:57 +00:00
parent 9abe3b29e0
commit 0e6681a069
8 changed files with 54 additions and 8 deletions

View File

@ -37,9 +37,11 @@
# include <windows.h>
#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;

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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 "

View File

@ -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},

View File

@ -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]))

View File

@ -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