Browse Source

Refactor extension detection, add VBO detection

pull/2/head
mittorn 6 years ago
parent
commit
23d0f33ad1
  1. 1
      engine/client/gl_local.h
  2. 310
      engine/platform/sdl/vid_sdl.c

1
engine/client/gl_local.h

@ -523,6 +523,7 @@ enum
GL_EXT_GPU_SHADER4, // shaders only GL_EXT_GPU_SHADER4, // shaders only
GL_DEPTH_TEXTURE, GL_DEPTH_TEXTURE,
GL_DEBUG_OUTPUT, GL_DEBUG_OUTPUT,
GL_ARB_VERTEX_BUFFER_OBJECT_EXT,
GL_EXTCOUNT, // must be last GL_EXTCOUNT, // must be last
}; };

310
engine/platform/sdl/vid_sdl.c

@ -25,175 +25,188 @@ GNU General Public License for more details.
static vidmode_t *vidmodes = NULL; static vidmode_t *vidmodes = NULL;
static int num_vidmodes = 0; static int num_vidmodes = 0;
static int context_flags = 0; static int context_flags = 0;
#define GL_CALL( x ) #x, (void**)&p##x
static dllfunc_t opengl_110funcs[] = static dllfunc_t opengl_110funcs[] =
{ {
{ "glClearColor" , (void **)&pglClearColor }, { GL_CALL( glClearColor ) },
{ "glClear" , (void **)&pglClear }, { GL_CALL( glClear ) },
{ "glAlphaFunc" , (void **)&pglAlphaFunc }, { GL_CALL( glAlphaFunc ) },
{ "glBlendFunc" , (void **)&pglBlendFunc }, { GL_CALL( glBlendFunc ) },
{ "glCullFace" , (void **)&pglCullFace }, { GL_CALL( glCullFace ) },
{ "glDrawBuffer" , (void **)&pglDrawBuffer }, { GL_CALL( glDrawBuffer ) },
{ "glReadBuffer" , (void **)&pglReadBuffer }, { GL_CALL( glReadBuffer ) },
{ "glAccum" , (void **)&pglAccum }, { GL_CALL( glAccum ) },
{ "glEnable" , (void **)&pglEnable }, { GL_CALL( glEnable ) },
{ "glDisable" , (void **)&pglDisable }, { GL_CALL( glDisable ) },
{ "glEnableClientState" , (void **)&pglEnableClientState }, { GL_CALL( glEnableClientState ) },
{ "glDisableClientState" , (void **)&pglDisableClientState }, { GL_CALL( glDisableClientState ) },
{ "glGetBooleanv" , (void **)&pglGetBooleanv }, { GL_CALL( glGetBooleanv ) },
{ "glGetDoublev" , (void **)&pglGetDoublev }, { GL_CALL( glGetDoublev ) },
{ "glGetFloatv" , (void **)&pglGetFloatv }, { GL_CALL( glGetFloatv ) },
{ "glGetIntegerv" , (void **)&pglGetIntegerv }, { GL_CALL( glGetIntegerv ) },
{ "glGetError" , (void **)&pglGetError }, { GL_CALL( glGetError ) },
{ "glGetString" , (void **)&pglGetString }, { GL_CALL( glGetString ) },
{ "glFinish" , (void **)&pglFinish }, { GL_CALL( glFinish ) },
{ "glFlush" , (void **)&pglFlush }, { GL_CALL( glFlush ) },
{ "glClearDepth" , (void **)&pglClearDepth }, { GL_CALL( glClearDepth ) },
{ "glDepthFunc" , (void **)&pglDepthFunc }, { GL_CALL( glDepthFunc ) },
{ "glDepthMask" , (void **)&pglDepthMask }, { GL_CALL( glDepthMask ) },
{ "glDepthRange" , (void **)&pglDepthRange }, { GL_CALL( glDepthRange ) },
{ "glFrontFace" , (void **)&pglFrontFace }, { GL_CALL( glFrontFace ) },
{ "glDrawElements" , (void **)&pglDrawElements }, { GL_CALL( glDrawElements ) },
{ "glDrawArrays" , (void **)&pglDrawArrays }, { GL_CALL( glDrawArrays ) },
{ "glColorMask" , (void **)&pglColorMask }, { GL_CALL( glColorMask ) },
{ "glIndexPointer" , (void **)&pglIndexPointer }, { GL_CALL( glIndexPointer ) },
{ "glVertexPointer" , (void **)&pglVertexPointer }, { GL_CALL( glVertexPointer ) },
{ "glNormalPointer" , (void **)&pglNormalPointer }, { GL_CALL( glNormalPointer ) },
{ "glColorPointer" , (void **)&pglColorPointer }, { GL_CALL( glColorPointer ) },
{ "glTexCoordPointer" , (void **)&pglTexCoordPointer }, { GL_CALL( glTexCoordPointer ) },
{ "glArrayElement" , (void **)&pglArrayElement }, { GL_CALL( glArrayElement ) },
{ "glColor3f" , (void **)&pglColor3f }, { GL_CALL( glColor3f ) },
{ "glColor3fv" , (void **)&pglColor3fv }, { GL_CALL( glColor3fv ) },
{ "glColor4f" , (void **)&pglColor4f }, { GL_CALL( glColor4f ) },
{ "glColor4fv" , (void **)&pglColor4fv }, { GL_CALL( glColor4fv ) },
{ "glColor3ub" , (void **)&pglColor3ub }, { GL_CALL( glColor3ub ) },
{ "glColor4ub" , (void **)&pglColor4ub }, { GL_CALL( glColor4ub ) },
{ "glColor4ubv" , (void **)&pglColor4ubv }, { GL_CALL( glColor4ubv ) },
{ "glTexCoord1f" , (void **)&pglTexCoord1f }, { GL_CALL( glTexCoord1f ) },
{ "glTexCoord2f" , (void **)&pglTexCoord2f }, { GL_CALL( glTexCoord2f ) },
{ "glTexCoord3f" , (void **)&pglTexCoord3f }, { GL_CALL( glTexCoord3f ) },
{ "glTexCoord4f" , (void **)&pglTexCoord4f }, { GL_CALL( glTexCoord4f ) },
{ "glTexCoord1fv" , (void **)&pglTexCoord1fv }, { GL_CALL( glTexCoord1fv ) },
{ "glTexCoord2fv" , (void **)&pglTexCoord2fv }, { GL_CALL( glTexCoord2fv ) },
{ "glTexCoord3fv" , (void **)&pglTexCoord3fv }, { GL_CALL( glTexCoord3fv ) },
{ "glTexCoord4fv" , (void **)&pglTexCoord4fv }, { GL_CALL( glTexCoord4fv ) },
{ "glTexGenf" , (void **)&pglTexGenf }, { GL_CALL( glTexGenf ) },
{ "glTexGenfv" , (void **)&pglTexGenfv }, { GL_CALL( glTexGenfv ) },
{ "glTexGeni" , (void **)&pglTexGeni }, { GL_CALL( glTexGeni ) },
{ "glVertex2f" , (void **)&pglVertex2f }, { GL_CALL( glVertex2f ) },
{ "glVertex3f" , (void **)&pglVertex3f }, { GL_CALL( glVertex3f ) },
{ "glVertex3fv" , (void **)&pglVertex3fv }, { GL_CALL( glVertex3fv ) },
{ "glNormal3f" , (void **)&pglNormal3f }, { GL_CALL( glNormal3f ) },
{ "glNormal3fv" , (void **)&pglNormal3fv }, { GL_CALL( glNormal3fv ) },
{ "glBegin" , (void **)&pglBegin }, { GL_CALL( glBegin ) },
{ "glEnd" , (void **)&pglEnd }, { GL_CALL( glEnd ) },
{ "glLineWidth" , (void**)&pglLineWidth }, { GL_CALL( glLineWidth ) },
{ "glPointSize" , (void**)&pglPointSize }, { GL_CALL( glPointSize ) },
{ "glMatrixMode" , (void **)&pglMatrixMode }, { GL_CALL( glMatrixMode ) },
{ "glOrtho" , (void **)&pglOrtho }, { GL_CALL( glOrtho ) },
{ "glRasterPos2f" , (void **) &pglRasterPos2f }, { GL_CALL( glRasterPos2f ) },
{ "glFrustum" , (void **)&pglFrustum }, { GL_CALL( glFrustum ) },
{ "glViewport" , (void **)&pglViewport }, { GL_CALL( glViewport ) },
{ "glPushMatrix" , (void **)&pglPushMatrix }, { GL_CALL( glPushMatrix ) },
{ "glPopMatrix" , (void **)&pglPopMatrix }, { GL_CALL( glPopMatrix ) },
{ "glPushAttrib" , (void **)&pglPushAttrib }, { GL_CALL( glPushAttrib ) },
{ "glPopAttrib" , (void **)&pglPopAttrib }, { GL_CALL( glPopAttrib ) },
{ "glLoadIdentity" , (void **)&pglLoadIdentity }, { GL_CALL( glLoadIdentity ) },
{ "glLoadMatrixd" , (void **)&pglLoadMatrixd }, { GL_CALL( glLoadMatrixd ) },
{ "glLoadMatrixf" , (void **)&pglLoadMatrixf }, { GL_CALL( glLoadMatrixf ) },
{ "glMultMatrixd" , (void **)&pglMultMatrixd }, { GL_CALL( glMultMatrixd ) },
{ "glMultMatrixf" , (void **)&pglMultMatrixf }, { GL_CALL( glMultMatrixf ) },
{ "glRotated" , (void **)&pglRotated }, { GL_CALL( glRotated ) },
{ "glRotatef" , (void **)&pglRotatef }, { GL_CALL( glRotatef ) },
{ "glScaled" , (void **)&pglScaled }, { GL_CALL( glScaled ) },
{ "glScalef" , (void **)&pglScalef }, { GL_CALL( glScalef ) },
{ "glTranslated" , (void **)&pglTranslated }, { GL_CALL( glTranslated ) },
{ "glTranslatef" , (void **)&pglTranslatef }, { GL_CALL( glTranslatef ) },
{ "glReadPixels" , (void **)&pglReadPixels }, { GL_CALL( glReadPixels ) },
{ "glDrawPixels" , (void **)&pglDrawPixels }, { GL_CALL( glDrawPixels ) },
{ "glStencilFunc" , (void **)&pglStencilFunc }, { GL_CALL( glStencilFunc ) },
{ "glStencilMask" , (void **)&pglStencilMask }, { GL_CALL( glStencilMask ) },
{ "glStencilOp" , (void **)&pglStencilOp }, { GL_CALL( glStencilOp ) },
{ "glClearStencil" , (void **)&pglClearStencil }, { GL_CALL( glClearStencil ) },
{ "glIsEnabled" , (void **)&pglIsEnabled }, { GL_CALL( glIsEnabled ) },
{ "glIsList" , (void **)&pglIsList }, { GL_CALL( glIsList ) },
{ "glIsTexture" , (void **)&pglIsTexture }, { GL_CALL( glIsTexture ) },
{ "glTexEnvf" , (void **)&pglTexEnvf }, { GL_CALL( glTexEnvf ) },
{ "glTexEnvfv" , (void **)&pglTexEnvfv }, { GL_CALL( glTexEnvfv ) },
{ "glTexEnvi" , (void **)&pglTexEnvi }, { GL_CALL( glTexEnvi ) },
{ "glTexParameterf" , (void **)&pglTexParameterf }, { GL_CALL( glTexParameterf ) },
{ "glTexParameterfv" , (void **)&pglTexParameterfv }, { GL_CALL( glTexParameterfv ) },
{ "glTexParameteri" , (void **)&pglTexParameteri }, { GL_CALL( glTexParameteri ) },
{ "glHint" , (void **)&pglHint }, { GL_CALL( glHint ) },
{ "glPixelStoref" , (void **)&pglPixelStoref }, { GL_CALL( glPixelStoref ) },
{ "glPixelStorei" , (void **)&pglPixelStorei }, { GL_CALL( glPixelStorei ) },
{ "glGenTextures" , (void **)&pglGenTextures }, { GL_CALL( glGenTextures ) },
{ "glDeleteTextures" , (void **)&pglDeleteTextures }, { GL_CALL( glDeleteTextures ) },
{ "glBindTexture" , (void **)&pglBindTexture }, { GL_CALL( glBindTexture ) },
{ "glTexImage1D" , (void **)&pglTexImage1D }, { GL_CALL( glTexImage1D ) },
{ "glTexImage2D" , (void **)&pglTexImage2D }, { GL_CALL( glTexImage2D ) },
{ "glTexSubImage1D" , (void **)&pglTexSubImage1D }, { GL_CALL( glTexSubImage1D ) },
{ "glTexSubImage2D" , (void **)&pglTexSubImage2D }, { GL_CALL( glTexSubImage2D ) },
{ "glCopyTexImage1D" , (void **)&pglCopyTexImage1D }, { GL_CALL( glCopyTexImage1D ) },
{ "glCopyTexImage2D" , (void **)&pglCopyTexImage2D }, { GL_CALL( glCopyTexImage2D ) },
{ "glCopyTexSubImage1D" , (void **)&pglCopyTexSubImage1D }, { GL_CALL( glCopyTexSubImage1D ) },
{ "glCopyTexSubImage2D" , (void **)&pglCopyTexSubImage2D }, { GL_CALL( glCopyTexSubImage2D ) },
{ "glScissor" , (void **)&pglScissor }, { GL_CALL( glScissor ) },
{ "glGetTexImage" , (void **)&pglGetTexImage }, { GL_CALL( glGetTexImage ) },
{ "glGetTexEnviv" , (void **)&pglGetTexEnviv }, { GL_CALL( glGetTexEnviv ) },
{ "glPolygonOffset" , (void **)&pglPolygonOffset }, { GL_CALL( glPolygonOffset ) },
{ "glPolygonMode" , (void **)&pglPolygonMode }, { GL_CALL( glPolygonMode ) },
{ "glPolygonStipple" , (void **)&pglPolygonStipple }, { GL_CALL( glPolygonStipple ) },
{ "glClipPlane" , (void **)&pglClipPlane }, { GL_CALL( glClipPlane ) },
{ "glGetClipPlane" , (void **)&pglGetClipPlane }, { GL_CALL( glGetClipPlane ) },
{ "glShadeModel" , (void **)&pglShadeModel }, { GL_CALL( glShadeModel ) },
{ "glGetTexLevelParameteriv" , (void **)&pglGetTexLevelParameteriv }, { GL_CALL( glGetTexLevelParameteriv ) },
{ "glGetTexLevelParameterfv" , (void **)&pglGetTexLevelParameterfv }, { GL_CALL( glGetTexLevelParameterfv ) },
{ "glFogfv" , (void **)&pglFogfv }, { GL_CALL( glFogfv ) },
{ "glFogf" , (void **)&pglFogf }, { GL_CALL( glFogf ) },
{ "glFogi" , (void **)&pglFogi }, { GL_CALL( glFogi ) },
{ NULL , NULL } { NULL , NULL }
}; };
static dllfunc_t debugoutputfuncs[] = static dllfunc_t debugoutputfuncs[] =
{ {
{ "glDebugMessageControlARB" , (void **)&pglDebugMessageControlARB }, { GL_CALL( glDebugMessageControlARB ) },
{ "glDebugMessageInsertARB" , (void **)&pglDebugMessageInsertARB }, { GL_CALL( glDebugMessageInsertARB ) },
{ "glDebugMessageCallbackARB" , (void **)&pglDebugMessageCallbackARB }, { GL_CALL( glDebugMessageCallbackARB ) },
{ "glGetDebugMessageLogARB" , (void **)&pglGetDebugMessageLogARB }, { GL_CALL( glGetDebugMessageLogARB ) },
{ NULL , NULL } { NULL , NULL }
}; };
static dllfunc_t multitexturefuncs[] = static dllfunc_t multitexturefuncs[] =
{ {
{ "glMultiTexCoord1fARB" , (void **)&pglMultiTexCoord1f }, { GL_CALL( glMultiTexCoord1f ) },
{ "glMultiTexCoord2fARB" , (void **)&pglMultiTexCoord2f }, { GL_CALL( glMultiTexCoord2f ) },
{ "glMultiTexCoord3fARB" , (void **)&pglMultiTexCoord3f }, { GL_CALL( glMultiTexCoord3f ) },
{ "glMultiTexCoord4fARB" , (void **)&pglMultiTexCoord4f }, { GL_CALL( glMultiTexCoord4f ) },
{ "glActiveTextureARB" , (void **)&pglActiveTexture }, { GL_CALL( glActiveTexture ) },
{ "glActiveTextureARB" , (void **)&pglActiveTextureARB }, { GL_CALL( glActiveTextureARB ) },
{ "glClientActiveTextureARB" , (void **)&pglClientActiveTexture }, { GL_CALL( glClientActiveTexture ) },
{ "glClientActiveTextureARB" , (void **)&pglClientActiveTextureARB }, { GL_CALL( glClientActiveTextureARB ) },
{ NULL , NULL } { NULL , NULL }
}; };
static dllfunc_t texture3dextfuncs[] = static dllfunc_t texture3dextfuncs[] =
{ {
{ "glTexImage3DEXT" , (void **)&pglTexImage3D }, { GL_CALL( glTexImage3D ) },
{ "glTexSubImage3DEXT" , (void **)&pglTexSubImage3D }, { GL_CALL( glTexSubImage3D ) },
{ "glCopyTexSubImage3DEXT" , (void **)&pglCopyTexSubImage3D }, { GL_CALL( glCopyTexSubImage3D ) },
{ NULL , NULL } { NULL , NULL }
}; };
static dllfunc_t texturecompressionfuncs[] = static dllfunc_t texturecompressionfuncs[] =
{ {
{ "glCompressedTexImage3DARB" , (void **)&pglCompressedTexImage3DARB }, { GL_CALL( glCompressedTexImage3DARB ) },
{ "glCompressedTexImage2DARB" , (void **)&pglCompressedTexImage2DARB }, { GL_CALL( glCompressedTexImage2DARB ) },
{ "glCompressedTexImage1DARB" , (void **)&pglCompressedTexImage1DARB }, { GL_CALL( glCompressedTexImage1DARB ) },
{ "glCompressedTexSubImage3DARB" , (void **)&pglCompressedTexSubImage3DARB }, { GL_CALL( glCompressedTexSubImage3DARB ) },
{ "glCompressedTexSubImage2DARB" , (void **)&pglCompressedTexSubImage2DARB }, { GL_CALL( glCompressedTexSubImage2DARB ) },
{ "glCompressedTexSubImage1DARB" , (void **)&pglCompressedTexSubImage1DARB }, { GL_CALL( glCompressedTexSubImage1DARB ) },
{ "glGetCompressedTexImageARB" , (void **)&pglGetCompressedTexImage }, { GL_CALL( glGetCompressedTexImage ) },
{ NULL , NULL }
};
static dllfunc_t vbofuncs[] =
{
{ GL_CALL( glBindBufferARB ) },
{ GL_CALL( glDeleteBuffersARB ) },
{ GL_CALL( glGenBuffersARB ) },
{ GL_CALL( glIsBufferARB ) },
{ GL_CALL( glMapBufferARB ) },
{ GL_CALL( glUnmapBufferARB ) }, // ,
{ GL_CALL( glBufferDataARB ) },
{ GL_CALL( glBufferSubDataARB ) },
{ NULL, NULL} { NULL, NULL}
}; };
@ -884,7 +897,6 @@ qboolean R_Init_Video( void )
return true; return true;
} }
#ifdef XASH_GLES #ifdef XASH_GLES
void GL_InitExtensionsGLES( void ) void GL_InitExtensionsGLES( void )
{ {
@ -1039,6 +1051,8 @@ void GL_InitExtensionsBigGL()
GL_CheckExtension( "GL_ARB_depth_buffer_float", NULL, "gl_arb_depth_float", GL_ARB_DEPTH_FLOAT_EXT ); GL_CheckExtension( "GL_ARB_depth_buffer_float", NULL, "gl_arb_depth_float", GL_ARB_DEPTH_FLOAT_EXT );
GL_CheckExtension( "GL_EXT_gpu_shader4", NULL, NULL, GL_EXT_GPU_SHADER4 ); // don't confuse users GL_CheckExtension( "GL_EXT_gpu_shader4", NULL, NULL, GL_EXT_GPU_SHADER4 ); // don't confuse users
GL_CheckExtension( "GL_ARB_shading_language_100", NULL, "gl_glslprogram", GL_SHADER_GLSL100_EXT ); GL_CheckExtension( "GL_ARB_shading_language_100", NULL, "gl_glslprogram", GL_SHADER_GLSL100_EXT );
GL_CheckExtension( "GL_ARB_vertex_buffer_object", vbofuncs, "gl_vertex_buffer_object", GL_ARB_VERTEX_BUFFER_OBJECT_EXT );
// rectangle textures support // rectangle textures support
GL_CheckExtension( "GL_ARB_texture_rectangle", NULL, "gl_texture_rectangle", GL_TEXTURE_2D_RECT_EXT ); GL_CheckExtension( "GL_ARB_texture_rectangle", NULL, "gl_texture_rectangle", GL_TEXTURE_2D_RECT_EXT );

Loading…
Cancel
Save