src/video/SDL_video.c
changeset 7210 5b35f3e503c4
parent 7195 d206c3a59b2e
child 7212 81b0d4773d47
     1.1 --- a/src/video/SDL_video.c	Tue May 21 22:04:14 2013 -0700
     1.2 +++ b/src/video/SDL_video.c	Wed May 22 01:31:04 2013 -0400
     1.3 @@ -2347,6 +2347,12 @@
     1.4      }
     1.5  }
     1.6  
     1.7 +static __inline__ SDL_bool
     1.8 +isAtLeastGL3(const char *verstr)
     1.9 +{
    1.10 +    return ( verstr && (SDL_atoi(verstr) >= 3) );
    1.11 +}
    1.12 +
    1.13  SDL_bool
    1.14  SDL_GL_ExtensionSupported(const char *extension)
    1.15  {
    1.16 @@ -2366,13 +2372,40 @@
    1.17      if (start && *start == '0') {
    1.18          return SDL_FALSE;
    1.19      }
    1.20 +
    1.21      /* Lookup the available extensions */
    1.22 +
    1.23      glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
    1.24 -    if (glGetStringFunc) {
    1.25 -        extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
    1.26 -    } else {
    1.27 -        extensions = NULL;
    1.28 +    if (!glGetStringFunc) {
    1.29 +        return SDL_FALSE;
    1.30      }
    1.31 +
    1.32 +    if (isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
    1.33 +        const GLubyte *(APIENTRY * glGetStringiFunc) (GLenum, GLuint);
    1.34 +        void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
    1.35 +        GLint num_exts = 0;
    1.36 +        GLint i;
    1.37 +
    1.38 +        glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi");
    1.39 +        glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
    1.40 +        if ((!glGetStringiFunc) || (!glGetIntegervFunc)) {
    1.41 +            return SDL_FALSE;
    1.42 +        }
    1.43 +
    1.44 +        glGetIntegervFunc(GL_NUM_EXTENSIONS, &num_exts);
    1.45 +        for (i = 0; i < num_exts; i++) {
    1.46 +            const char *thisext = (const char *) glGetStringiFunc(GL_EXTENSIONS, i);
    1.47 +            if (SDL_strcmp(thisext, extension) == 0) {
    1.48 +                return SDL_TRUE;
    1.49 +            }
    1.50 +        }
    1.51 +
    1.52 +        return SDL_FALSE;
    1.53 +    }
    1.54 +
    1.55 +    /* Try the old way with glGetString(GL_EXTENSIONS) ... */
    1.56 +
    1.57 +    extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
    1.58      if (!extensions) {
    1.59          return SDL_FALSE;
    1.60      }