iOS: Fixed SDL_GL_CreateContext crashing instead of returning null when a GLES3 context is requested on iOS 6 and older.
authorAlex Szpakowski <slime73@gmail.com>
Sun, 10 Apr 2016 22:07:10 -0300
changeset 1014314719cd1bde2
parent 10142 bc8ac6c0cd98
child 10144 aa9904a56acf
iOS: Fixed SDL_GL_CreateContext crashing instead of returning null when a GLES3 context is requested on iOS 6 and older.
src/video/uikit/SDL_uikitopengles.m
     1.1 --- a/src/video/uikit/SDL_uikitopengles.m	Mon Apr 04 22:49:13 2016 -0400
     1.2 +++ b/src/video/uikit/SDL_uikitopengles.m	Sun Apr 10 22:07:10 2016 -0300
     1.3 @@ -140,10 +140,19 @@
     1.4          EAGLSharegroup *sharegroup = nil;
     1.5          CGFloat scale = 1.0;
     1.6          int samples = 0;
     1.7 +        int major = _this->gl_config.major_version;
     1.8 +        int minor = _this->gl_config.minor_version;
     1.9  
    1.10          /* The EAGLRenderingAPI enum values currently map 1:1 to major GLES
    1.11           * versions. */
    1.12 -        EAGLRenderingAPI api = _this->gl_config.major_version;
    1.13 +        EAGLRenderingAPI api = major;
    1.14 +
    1.15 +        /* iOS currently doesn't support GLES >3.0. iOS 6 also only supports up
    1.16 +         * to GLES 2.0. */
    1.17 +        if (major > 3 || (major == 3 && (minor > 0 || !UIKit_IsSystemVersionAtLeast(7.0)))) {
    1.18 +            SDL_SetError("OpenGL ES %d.%d context could not be created", major, minor);
    1.19 +            return NULL;
    1.20 +        }
    1.21  
    1.22          if (_this->gl_config.multisamplebuffers > 0) {
    1.23              samples = _this->gl_config.multisamplesamples;