Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Use glGetStringi() for extension lookup on OpenGL contexts >= version…

… 3.0.

Fixes Bugzilla #1620.
  • Loading branch information
icculus committed May 22, 2013
1 parent 8ac1608 commit 144f26090cd10dd0e5ee35c72b33e9ab52e56093
Showing with 37 additions and 4 deletions.
  1. +37 −4 src/video/SDL_video.c
@@ -2347,6 +2347,12 @@ SDL_GL_UnloadLibrary(void)
}
}

static __inline__ SDL_bool
isAtLeastGL3(const char *verstr)
{
return ( verstr && (SDL_atoi(verstr) >= 3) );
}

SDL_bool
SDL_GL_ExtensionSupported(const char *extension)
{
@@ -2366,13 +2372,40 @@ SDL_GL_ExtensionSupported(const char *extension)
if (start && *start == '0') {
return SDL_FALSE;
}

/* Lookup the available extensions */

glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
if (glGetStringFunc) {
extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
} else {
extensions = NULL;
if (!glGetStringFunc) {
return SDL_FALSE;
}

if (isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
const GLubyte *(APIENTRY * glGetStringiFunc) (GLenum, GLuint);
void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
GLint num_exts = 0;
GLint i;

glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi");
glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
if ((!glGetStringiFunc) || (!glGetIntegervFunc)) {
return SDL_FALSE;
}

glGetIntegervFunc(GL_NUM_EXTENSIONS, &num_exts);
for (i = 0; i < num_exts; i++) {
const char *thisext = (const char *) glGetStringiFunc(GL_EXTENSIONS, i);
if (SDL_strcmp(thisext, extension) == 0) {
return SDL_TRUE;
}
}

return SDL_FALSE;
}

/* Try the old way with glGetString(GL_EXTENSIONS) ... */

extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
if (!extensions) {
return SDL_FALSE;
}

0 comments on commit 144f260

Please sign in to comment.