From f7de4ae130e8580f8b0165f2849e20284a2343d5 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 22 Feb 2014 15:23:09 -0800 Subject: [PATCH] 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 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m index c6daa1e43eb25..5c163c9a099cf 100644 --- a/src/video/uikit/SDL_uikitopenglview.m +++ b/src/video/uikit/SDL_uikitopenglview.m @@ -56,6 +56,11 @@ - (id)initWithFrame:(CGRect)frame const BOOL useDepthBuffer = (depthBits != 0); NSString *colorFormat = nil; + /* The EAGLRenderingAPI enum values currently map 1:1 to major GLES + versions, and this allows us to handle future OpenGL ES versions. + */ + EAGLRenderingAPI api = majorVersion; + if (rBits == 8 && gBits == 8 && bBits == 8) { /* if user specifically requests rbg888 or some color format higher than 16bpp */ colorFormat = kEAGLColorFormatRGBA8; @@ -71,11 +76,7 @@ - (id)initWithFrame:(CGRect)frame eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil]; - if (majorVersion > 1) { - context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup:shareGroup]; - } else { - context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1 sharegroup:shareGroup]; - } + context = [[EAGLContext alloc] initWithAPI:api sharegroup:shareGroup]; if (!context || ![EAGLContext setCurrentContext:context]) { [self release]; SDL_SetError("OpenGL ES %d not supported", majorVersion);