Fixed bug 2407 - Support for OpenGL ES 3 contexts on iOS
authorSam Lantinga
Sat, 22 Feb 2014 15:23:09 -0800
changeset 8233ffece8ab18a6
parent 8232 8976fb30952f
child 8234 80c193c7c8c8
Fixed bug 2407 - Support for OpenGL ES 3 contexts on iOS

Alex Szpakowski

Currently the UIKit/EAGL backend for SDL's OpenGL context creation API doesn't support OpenGL ES 3, despite iOS 7+ being capable (on devices with the necessary hardware.)

I have attached a patch to add support. It's also slightly more future-proof, so eventual OpenGL ES 4+ capability on iOS should hopefully work without requiring changes to SDL's UIKit/EAGL backend.
src/video/uikit/SDL_uikitopenglview.m
     1.1 --- a/src/video/uikit/SDL_uikitopenglview.m	Sat Feb 22 14:57:12 2014 -0800
     1.2 +++ b/src/video/uikit/SDL_uikitopenglview.m	Sat Feb 22 15:23:09 2014 -0800
     1.3 @@ -56,6 +56,11 @@
     1.4          const BOOL useDepthBuffer = (depthBits != 0);
     1.5          NSString *colorFormat = nil;
     1.6  
     1.7 +        /* The EAGLRenderingAPI enum values currently map 1:1 to major GLES
     1.8 +           versions, and this allows us to handle future OpenGL ES versions.
     1.9 +         */
    1.10 +        EAGLRenderingAPI api = majorVersion;
    1.11 +
    1.12          if (rBits == 8 && gBits == 8 && bBits == 8) {
    1.13              /* if user specifically requests rbg888 or some color format higher than 16bpp */
    1.14              colorFormat = kEAGLColorFormatRGBA8;
    1.15 @@ -71,11 +76,7 @@
    1.16          eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
    1.17                                          [NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil];
    1.18  
    1.19 -        if (majorVersion > 1) {
    1.20 -            context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup:shareGroup];
    1.21 -        } else {
    1.22 -            context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1 sharegroup:shareGroup];
    1.23 -        }
    1.24 +        context = [[EAGLContext alloc] initWithAPI:api sharegroup:shareGroup];
    1.25          if (!context || ![EAGLContext setCurrentContext:context]) {
    1.26              [self release];
    1.27              SDL_SetError("OpenGL ES %d not supported", majorVersion);