src/video/cocoa/SDL_cocoaopengl.m
changeset 8604 459bd7365e9d
parent 8601 4c04c7785cba
child 8986 1c81316ac642
     1.1 --- a/src/video/cocoa/SDL_cocoaopengl.m	Mon Mar 10 19:11:52 2014 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoaopengl.m	Mon Mar 10 19:59:06 2014 -0700
     1.3 @@ -162,9 +162,6 @@
     1.4  Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
     1.5  {
     1.6      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
     1.7 -/*
     1.8 -    const GLubyte *(APIENTRY * glGetStringFunc)(GLenum) = NULL;
     1.9 -*/
    1.10      NSAutoreleasePool *pool;
    1.11      SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    1.12      SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
    1.13 @@ -278,49 +275,46 @@
    1.14          return NULL;
    1.15      }
    1.16  
    1.17 -/* No other backend does this version checking.
    1.18 -   If we enable it, we should consider whether it should be done at a 
    1.19 -   higher level for all platforms. We'll have to think through the implications
    1.20 -   of this.
    1.21 +    if (_this->gl_config.major_version < 3 &&
    1.22 +        _this->gl_config.profile_mask == 0 &&
    1.23 +        _this->gl_config.flags == 0) {
    1.24 +        /* This is a legacy profile, so to match other backends, we're done. */
    1.25 +    } else {
    1.26 +        const GLubyte *(APIENTRY * glGetStringFunc)(GLenum);
    1.27  
    1.28 -   For example, Mac OS X 10.6 will only report OpenGL 2.0, but we ask for 2.1
    1.29 -   by default. If we don't get 2.1, then the renderer will set the requested
    1.30 -   version and try to recreate the window, which causes all kinds of problems.
    1.31 +        glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glGetString");
    1.32 +        if (!glGetStringFunc) {
    1.33 +            Cocoa_GL_DeleteContext(_this, context);
    1.34 +            SDL_SetError ("Failed getting OpenGL glGetString entry point");
    1.35 +            return NULL;
    1.36 +        }
    1.37  
    1.38 -   For now, we'll just disable this code until we can think about it more.
    1.39 -*/
    1.40 -#if 0
    1.41 -    glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glGetString");
    1.42 -    if (!glGetStringFunc) {
    1.43 -        Cocoa_GL_DeleteContext(_this, context);
    1.44 -        SDL_SetError ("Failed getting OpenGL glGetString entry point");
    1.45 -        return NULL;
    1.46 +        glversion = (const char *)glGetStringFunc(GL_VERSION);
    1.47 +        if (glversion == NULL) {
    1.48 +            Cocoa_GL_DeleteContext(_this, context);
    1.49 +            SDL_SetError ("Failed getting OpenGL context version");
    1.50 +            return NULL;
    1.51 +        }
    1.52 +
    1.53 +        if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) {
    1.54 +            Cocoa_GL_DeleteContext(_this, context);
    1.55 +            SDL_SetError ("Failed parsing OpenGL context version");
    1.56 +            return NULL;
    1.57 +        }
    1.58 +
    1.59 +        if ((glversion_major < _this->gl_config.major_version) ||
    1.60 +           ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) {
    1.61 +            Cocoa_GL_DeleteContext(_this, context);
    1.62 +            SDL_SetError ("Failed creating OpenGL context at version requested");
    1.63 +            return NULL;
    1.64 +        }
    1.65 +
    1.66 +        /* In the future we'll want to do this, but to match other platforms
    1.67 +           we'll leave the OpenGL version the way it is for now
    1.68 +         */
    1.69 +        /*_this->gl_config.major_version = glversion_major;*/
    1.70 +        /*_this->gl_config.minor_version = glversion_minor;*/
    1.71      }
    1.72 -
    1.73 -    glversion = (const char *)glGetStringFunc(GL_VERSION);
    1.74 -    if (glversion == NULL) {
    1.75 -        Cocoa_GL_DeleteContext(_this, context);
    1.76 -        SDL_SetError ("Failed getting OpenGL context version");
    1.77 -        return NULL;
    1.78 -    }
    1.79 -
    1.80 -    if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) {
    1.81 -        Cocoa_GL_DeleteContext(_this, context);
    1.82 -        SDL_SetError ("Failed parsing OpenGL context version");
    1.83 -        return NULL;
    1.84 -    }
    1.85 -
    1.86 -    if ((glversion_major <  _this->gl_config.major_version) ||
    1.87 -       ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) {
    1.88 -        Cocoa_GL_DeleteContext(_this, context);
    1.89 -        SDL_SetError ("Failed creating OpenGL context at version requested");
    1.90 -        return NULL;
    1.91 -    }
    1.92 -
    1.93 -    _this->gl_config.major_version = glversion_major;
    1.94 -    _this->gl_config.minor_version = glversion_minor;
    1.95 -#endif
    1.96 -
    1.97      return context;
    1.98  }
    1.99