Still broken, but apparently it works for Mercury.

This commit is contained in:
Jeff Teunissen 2001-06-26 02:59:37 +00:00
parent 749d460041
commit d485ca1fb1

View file

@ -51,7 +51,7 @@
// First we need to get all the function pointers declared. // First we need to get all the function pointers declared.
#define QFGL_NEED(ret, name, args) \ #define QFGL_NEED(ret, name, args) \
ret (* name) args = NULL; ret (* qf##name) args = NULL;
#include "QF/GL/qf_funcs_list.h" #include "QF/GL/qf_funcs_list.h"
#undef QFGL_NEED #undef QFGL_NEED
@ -61,25 +61,22 @@ GLF_Init (void)
{ {
void *handle; void *handle;
#ifdef HAVE_DLOPEN #if defined(HAVE_DLOPEN)
if (!(handle = dlopen (gl_libgl->string, RTLD_NOW))) { if (!(handle = dlopen (gl_libgl->string, RTLD_NOW))) {
Sys_Error ("Couldn't load OpenGL library %s: %s\n", gl_libgl->string, dlerror ()); Sys_Error ("Couldn't load OpenGL library %s: %s\n", gl_libgl->string, dlerror ());
return false; return false;
} }
#else #elif defined(_WIN32)
# if _WIN32
if (!(handle = LoadLibrary (gl_libgl->string))) { if (!(handle = LoadLibrary (gl_libgl->string))) {
Sys_Error ("Couldn't load OpenGL library %s!\n", gl_libgl->string); Sys_Error ("Couldn't load OpenGL library %s!\n", gl_libgl->string);
return false; return false;
} }
# else #else
Sys_Error ("Cannot load libraries: %s was built without DSO support", PROGRAM); # error "Cannot load libraries: %s was not configured with DSO support"
return false;
# endif
#endif #endif
#define QFGL_NEED(ret, name, args) \ #define QFGL_NEED(ret, name, args) \
name = QFGL_ProcAddress (handle, #name); qf##name = QFGL_ProcAddress (handle, #name);
#include "QF/GL/qf_funcs_list.h" #include "QF/GL/qf_funcs_list.h"
#undef QFGL_NEED #undef QFGL_NEED
@ -94,47 +91,47 @@ QFGL_ProcAddress (void *handle, const char *name)
static qboolean inited = false; static qboolean inited = false;
void *glfunc = NULL; void *glfunc = NULL;
#ifdef HAVE_DLOPEN #if defined(HAVE_DLOPEN)
static QF_glXGetProcAddressARB glGetProcAddress = NULL; static QF_glXGetProcAddressARB glGetProcAddress = NULL;
#else #elif defined(_WIN32)
# ifdef _WIN32
static void * (* wglGetProcAddress) (char *) glGetProcAddress = NULL; static void * (* wglGetProcAddress) (char *) glGetProcAddress = NULL;
# endif #else
static void *glGetProcAddress = NULL;
#endif #endif
if (!handle || !name) if (!handle || !name) {
inited = false;
return NULL; return NULL;
}
if (!inited) { if (!inited) {
inited = true; inited = true;
#ifdef HAVE_DLOPEN #if defined(HAVE_DLOPEN)
glGetProcAddress = dlsym (handle, "glXGetProcAddressARB"); glGetProcAddress = dlsym (handle, "glXGetProcAddressARB");
#else #elif defined(_WIN32)
# ifdef _WIN32
glGetProcAddress = GetProcAddress (handle, "wglGetProcAddress"); glGetProcAddress = GetProcAddress (handle, "wglGetProcAddress");
# endif
#endif #endif
} }
Sys_Printf ("DEBUG: Finding symbol %s ... ", name); Sys_Printf ("DEBUG: Finding symbol %s ... ", name);
#ifdef HAVE_DLOPEN #if defined(HAVE_DLOPEN)
if (glGetProcAddress)
glfunc = glGetProcAddress (name);
else
glfunc = dlsym (handle, name); glfunc = dlsym (handle, name);
#else #elif defined(_WIN32)
# ifdef _WIN32
if (glGetProcAddress)
glfunc = glGetProcAddress (name);
else
glfunc = GetProcAddress (handle, name); glfunc = GetProcAddress (handle, name);
# endif
#endif #endif
if (glfunc) { if (glGetProcAddress && glfunc != glGetProcAddress (name)) {
Sys_Printf ("found [0x%x]\n", (unsigned int) glfunc); Con_Printf ("mismatch! [%p != %p]\n", glfunc, glGetProcAddress (name));
return glfunc; return glfunc;
} else {
Sys_Printf ("not found\n");
return NULL;
} }
if (!glfunc && glGetProcAddress)
glfunc = glGetProcAddress (name);
if (glfunc) {
Con_Printf ("found [%p]\n", glfunc);
return glfunc;
}
Con_Printf ("not found\n");
return NULL;
} }