diff --git a/src/backends/generic/header/qgl.h b/src/backends/generic/header/qgl.h index bcedd33d..5b781b82 100644 --- a/src/backends/generic/header/qgl.h +++ b/src/backends/generic/header/qgl.h @@ -494,7 +494,9 @@ extern void (APIENTRY *qglSelectTextureSGIS)(GLenum); extern void (APIENTRY *qglActiveTextureARB)(GLenum); extern void (APIENTRY *qglClientActiveTextureARB)(GLenum); -extern void *qwglGetProcAddress(char *symbol); +extern void *GetProcAddressGL(char *symbol); + +extern void *(APIENTRY *qwglGetProcAddress)(char *symbol); #ifdef _WIN32 diff --git a/src/backends/generic/qgl.c b/src/backends/generic/qgl.c index 4f580d90..ec1bd895 100644 --- a/src/backends/generic/qgl.c +++ b/src/backends/generic/qgl.c @@ -35,6 +35,8 @@ #include "../../refresh/header/local.h" #include "header/glwindow.h" +void *(APIENTRY *qwglGetProcAddress)(char *symbol); + void (APIENTRY *qglAccum)(GLenum op, GLfloat value); void (APIENTRY *qglAlphaFunc)(GLenum func, GLclampf ref); GLboolean (APIENTRY *qglAreTexturesResident)(GLsizei n, const GLuint *textures, @@ -3274,6 +3276,8 @@ QGL_Shutdown(void) glw_state.OpenGLLib = NULL; + qwglGetProcAddress = NULL; + qglAccum = NULL; qglAlphaFunc = NULL; qglAreTexturesResident = NULL; @@ -3612,15 +3616,27 @@ QGL_Shutdown(void) qglViewport = NULL; } +/* + * Special case function to return addresses of non + * base functions in libGL. The system wide function + * can't be used since on Windows wglGetProcAddress + * is required instead of GetProcAddress(). + */ void * -qwglGetProcAddress(char *symbol) +GetProcAddressGL(char *symbol) { - if (glw_state.OpenGLLib) + if (qwglGetProcAddress) + { + return qwglGetProcAddress(symbol); + } + else if (glw_state.OpenGLLib) { return ri.Sys_GetProcAddress(glw_state.OpenGLLib, symbol); } - - return NULL; + else + { + return NULL; + } } /* @@ -4014,6 +4030,9 @@ QGL_Init(const char *dllname) qglVertexPointer = dllVertexPointer = ri.Sys_GetProcAddress(glw_state.OpenGLLib, "glVertexPointer"); qglViewport = dllViewport = ri.Sys_GetProcAddress(glw_state.OpenGLLib, "glViewport"); + /* Connect wglGetProcAddress (only available on Windows, otherwise NULL */ + qwglGetProcAddress = ri.Sys_GetProcAddress(glw_state.OpenGLLib, "wglGetProcAddress"); + qglLockArraysEXT = 0; qglUnlockArraysEXT = 0; qglPointParameterfEXT = 0; diff --git a/src/refresh/r_main.c b/src/refresh/r_main.c index 440fc724..a0d5a783 100644 --- a/src/refresh/r_main.c +++ b/src/refresh/r_main.c @@ -1188,8 +1188,8 @@ R_Init(void *hinstance, void *hWnd) strstr(gl_config.extensions_string, "GL_SGI_compiled_vertex_array")) { ri.Con_Printf(PRINT_ALL, "...enabling GL_EXT_compiled_vertex_array\n"); - qglLockArraysEXT = (void *)qwglGetProcAddress("glLockArraysEXT"); - qglUnlockArraysEXT = (void *)qwglGetProcAddress("glUnlockArraysEXT"); + qglLockArraysEXT = (void *)GetProcAddressGL("glLockArraysEXT"); + qglUnlockArraysEXT = (void *)GetProcAddressGL("glUnlockArraysEXT"); } else { @@ -1201,9 +1201,9 @@ R_Init(void *hinstance, void *hWnd) if (gl_ext_pointparameters->value) { qglPointParameterfEXT = (void (APIENTRY *)(GLenum, GLfloat)) - qwglGetProcAddress("glPointParameterfEXT"); + GetProcAddressGL("glPointParameterfEXT"); qglPointParameterfvEXT = (void (APIENTRY *)(GLenum, const GLfloat *)) - qwglGetProcAddress("glPointParameterfvEXT"); + GetProcAddressGL("glPointParameterfvEXT"); ri.Con_Printf(PRINT_ALL, "...using GL_EXT_point_parameters\n"); } else @@ -1225,7 +1225,7 @@ R_Init(void *hinstance, void *hWnd) ri.Con_Printf(PRINT_ALL, "...using GL_EXT_shared_texture_palette\n"); qglColorTableEXT = (void (APIENTRY *)(GLenum, GLenum, GLsizei, GLenum, GLenum, - const GLvoid *))qwglGetProcAddress( + const GLvoid *))GetProcAddressGL( "glColorTableEXT"); } else @@ -1244,12 +1244,9 @@ R_Init(void *hinstance, void *hWnd) if (gl_ext_multitexture->value) { ri.Con_Printf(PRINT_ALL, "...using GL_ARB_multitexture\n"); - qglMTexCoord2fSGIS = (void *)qwglGetProcAddress( - "glMultiTexCoord2fARB"); - qglActiveTextureARB = (void *)qwglGetProcAddress( - "glActiveTextureARB"); - qglClientActiveTextureARB = (void *)qwglGetProcAddress( - "glClientActiveTextureARB"); + qglMTexCoord2fSGIS = (void *)GetProcAddressGL("glMultiTexCoord2fARB"); + qglActiveTextureARB = (void *)GetProcAddressGL("glActiveTextureARB"); + qglClientActiveTextureARB = (void *)GetProcAddressGL("glClientActiveTextureARB"); QGL_TEXTURE0 = GL_TEXTURE0_ARB; QGL_TEXTURE1 = GL_TEXTURE1_ARB; } @@ -1273,9 +1270,8 @@ R_Init(void *hinstance, void *hWnd) else if (gl_ext_multitexture->value) { ri.Con_Printf(PRINT_ALL, "...using GL_SGIS_multitexture\n"); - qglMTexCoord2fSGIS = (void *)qwglGetProcAddress("glMTexCoord2fSGIS"); - qglSelectTextureSGIS = (void *)qwglGetProcAddress( - "glSelectTextureSGIS"); + qglMTexCoord2fSGIS = (void *)GetProcAddressGL("glMTexCoord2fSGIS"); + qglSelectTextureSGIS = (void *)GetProcAddressGL("glSelectTextureSGIS"); QGL_TEXTURE0 = GL_TEXTURE0_SGIS; QGL_TEXTURE1 = GL_TEXTURE1_SGIS; }