2002-03-11 23:55:50 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2001-11-27 23:56:10 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
#include <X11/cursorfont.h>
|
|
|
|
|
|
|
|
#include "QF/GL/defines.h"
|
2002-03-11 23:55:50 +00:00
|
|
|
#include "QF/GL/extensions.h"
|
2001-11-27 23:56:10 +00:00
|
|
|
#include "QF/GL/types.h"
|
|
|
|
|
2002-03-11 23:55:50 +00:00
|
|
|
#include "QF/hash.h"
|
2001-11-27 23:56:10 +00:00
|
|
|
|
2002-03-11 23:55:50 +00:00
|
|
|
typedef XID GLXDrawable;
|
|
|
|
typedef struct __GLXcontextRec *GLXContext;
|
2001-11-27 23:56:10 +00:00
|
|
|
|
2002-12-10 15:30:16 +00:00
|
|
|
#define TRACE do { \
|
|
|
|
puts (__FUNCTION__);\
|
|
|
|
} while (0)
|
|
|
|
|
2002-03-11 23:55:50 +00:00
|
|
|
#define QFGL_DONT_NEED(ret, func, params) QFGL_NEED(ret, func, params)
|
2001-11-27 23:56:10 +00:00
|
|
|
|
2004-01-28 02:49:57 +00:00
|
|
|
#undef QFGL_WANT
|
2002-03-11 23:55:50 +00:00
|
|
|
#undef QFGL_NEED
|
2001-11-27 23:56:10 +00:00
|
|
|
|
2004-01-28 02:49:57 +00:00
|
|
|
#define QFGL_WANT(ret, name, args) \
|
|
|
|
ret GLAPIENTRY norm_##name args;
|
2002-03-11 23:55:50 +00:00
|
|
|
#define QFGL_NEED(ret, name, args) \
|
|
|
|
ret GLAPIENTRY norm_##name args;
|
|
|
|
#include "QF/GL/qf_funcs_list.h"
|
|
|
|
#undef QFGL_NEED
|
2004-01-28 02:49:57 +00:00
|
|
|
#undef QFGL_WANT
|
2001-11-27 23:56:10 +00:00
|
|
|
|
2004-01-28 02:49:57 +00:00
|
|
|
#define QFGL_WANT(ret, name, args) \
|
|
|
|
ret GLAPIENTRY trace_##name args;
|
2002-03-11 23:55:50 +00:00
|
|
|
#define QFGL_NEED(ret, name, args) \
|
|
|
|
ret GLAPIENTRY trace_##name args;
|
|
|
|
#include "QF/GL/qf_funcs_list.h"
|
|
|
|
#undef QFGL_NEED
|
2004-01-28 02:49:57 +00:00
|
|
|
#undef QFGL_WANT
|
2001-11-27 23:56:10 +00:00
|
|
|
|
2002-03-11 23:55:50 +00:00
|
|
|
typedef struct {
|
|
|
|
const char *name;
|
|
|
|
void *norm;
|
|
|
|
void *trace;
|
|
|
|
} gl_stub_t;
|
2001-11-27 23:56:10 +00:00
|
|
|
|
2002-12-10 15:30:16 +00:00
|
|
|
static int trace;
|
|
|
|
|
2002-03-11 23:55:50 +00:00
|
|
|
static gl_stub_t gl_stub_funcs[] = {
|
2004-01-28 02:49:57 +00:00
|
|
|
#define QFGL_WANT(ret, name, args) \
|
|
|
|
{#name, norm_##name, trace_##name},
|
2002-03-11 23:55:50 +00:00
|
|
|
#define QFGL_NEED(ret, name, args) \
|
|
|
|
{#name, norm_##name, trace_##name},
|
|
|
|
#include "QF/GL/qf_funcs_list.h"
|
|
|
|
#undef QFGL_NEED
|
2004-01-28 02:49:57 +00:00
|
|
|
#undef QFGL_WANT
|
2002-03-11 23:55:50 +00:00
|
|
|
};
|
2001-11-27 23:56:10 +00:00
|
|
|
|
2002-03-11 23:55:50 +00:00
|
|
|
#define NUM_FUNCS (sizeof (gl_stub_funcs) / sizeof (gl_stub_funcs[0]))
|
2001-11-27 23:56:10 +00:00
|
|
|
|
2002-03-11 23:55:50 +00:00
|
|
|
static int
|
|
|
|
cmp (const void *a, const void *b)
|
2001-11-27 23:56:10 +00:00
|
|
|
{
|
2002-03-11 23:55:50 +00:00
|
|
|
return strcmp (((gl_stub_t *)a)->name, ((gl_stub_t *)b)->name);
|
2001-11-27 23:56:10 +00:00
|
|
|
}
|
|
|
|
|
2002-03-11 23:55:50 +00:00
|
|
|
void *
|
|
|
|
glXGetProcAddressARB (const GLubyte *procName)
|
2001-11-27 23:56:10 +00:00
|
|
|
{
|
2002-03-11 23:55:50 +00:00
|
|
|
static int called;
|
|
|
|
gl_stub_t *stub;
|
|
|
|
gl_stub_t key;
|
2002-12-10 18:25:11 +00:00
|
|
|
|
2002-03-11 23:55:50 +00:00
|
|
|
if (!called) {
|
2002-03-12 00:07:43 +00:00
|
|
|
char *glstub_trace;
|
|
|
|
|
2002-03-11 23:55:50 +00:00
|
|
|
qsort (gl_stub_funcs, NUM_FUNCS, sizeof (gl_stub_t), cmp);
|
|
|
|
called = 1;
|
2002-03-12 00:07:43 +00:00
|
|
|
|
|
|
|
glstub_trace = getenv ("GLSTUB_TRACE");
|
|
|
|
if (glstub_trace)
|
|
|
|
trace = atoi (glstub_trace);
|
2001-11-27 23:56:10 +00:00
|
|
|
}
|
2002-03-11 23:55:50 +00:00
|
|
|
key.name = procName;
|
|
|
|
stub = bsearch (&key, gl_stub_funcs, NUM_FUNCS, sizeof (gl_stub_t), cmp);
|
|
|
|
if (!stub)
|
|
|
|
return 0;
|
2002-03-12 00:07:43 +00:00
|
|
|
return trace ? stub->trace : stub->norm;
|
2001-11-27 23:56:10 +00:00
|
|
|
}
|
2002-12-10 15:30:16 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
glXSwapBuffers (Display *dpy, GLXDrawable drawable)
|
|
|
|
{
|
|
|
|
if (trace)
|
|
|
|
TRACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
XVisualInfo*
|
|
|
|
glXChooseVisual (Display *dpy, int screen, int *attribList)
|
|
|
|
{
|
|
|
|
XVisualInfo template;
|
|
|
|
int num_visuals;
|
|
|
|
int template_mask;
|
|
|
|
|
|
|
|
if (trace)
|
|
|
|
TRACE;
|
|
|
|
|
|
|
|
template_mask = 0;
|
|
|
|
template.visualid =
|
|
|
|
XVisualIDFromVisual (XDefaultVisual (dpy, screen));
|
|
|
|
template_mask = VisualIDMask;
|
|
|
|
return XGetVisualInfo (dpy, template_mask, &template, &num_visuals);
|
|
|
|
}
|
|
|
|
|
|
|
|
GLXContext
|
|
|
|
glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList,
|
|
|
|
Bool direct)
|
|
|
|
{
|
|
|
|
if (trace)
|
|
|
|
TRACE;
|
|
|
|
return (GLXContext)1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx)
|
|
|
|
{
|
|
|
|
if (trace)
|
|
|
|
TRACE;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
glXDestroyContext (Display *dpy, GLXContext ctx )
|
|
|
|
{
|
|
|
|
if (trace)
|
|
|
|
TRACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
glXGetConfig (Display *dpy, XVisualInfo *visual, int attrib, int *value )
|
|
|
|
{
|
|
|
|
if (trace)
|
|
|
|
TRACE;
|
|
|
|
return 0;
|
|
|
|
}
|