mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-25 22:10:59 +00:00
Connect non-base OpenGL function by calling wglGetProcAddress() on Windows
This is necessary since non-base OpenGL functions can't be connected by calling the standard GetProcAddress() on Windows. To archive this the old qwglGetProcAdress() is renamed into GetProcAdressGL() and a new function pointer qwglGetProcAdress is introduced. On unixoid System it's NULL and on Windows connected to wglGetProcAddress(). If it's NULL the system wide function is called, if not the function Pointer is used.
This commit is contained in:
parent
739590e639
commit
602dd1af6f
3 changed files with 36 additions and 19 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue