summaryrefslogtreecommitdiff
path: root/platform/iphone/gl_view.mm
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-03-16 10:38:51 -0700
committerGitHub <noreply@github.com>2019-03-16 10:38:51 -0700
commitb00c96a861fbbdcdb341784a53675b5787ec2c0c (patch)
tree24756b252c1519b9f4b72086beab5c3b99fcdca5 /platform/iphone/gl_view.mm
parentda8c2deefad85f7e98e40c3615cc2d18a42d03ad (diff)
parent4946335d3de3115e6aa9f9685bb595e9de96d5c3 (diff)
Merge pull request #27071 from samgreen/ios_gles2_fix
Resolve GLES 2 crash on older iOS devices
Diffstat (limited to 'platform/iphone/gl_view.mm')
-rw-r--r--platform/iphone/gl_view.mm32
1 files changed, 25 insertions, 7 deletions
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index 6f4d0ddb57..1cb8d0e44e 100644
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -284,19 +284,37 @@ static void clear_touches() {
kEAGLColorFormatRGBA8,
kEAGLDrawablePropertyColorFormat,
nil];
+ bool fallback_gl2 = false;
+ // Create a GL ES 3 context based on the gl driver from project settings
+ if (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES3") {
+ context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
+ NSLog(@"Setting up an OpenGL ES 3.0 context. Based on Project Settings \"rendering/quality/driver/driver_name\"");
+ if (!context && GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
+ gles3_available = false;
+ fallback_gl2 = true;
+ NSLog(@"Failed to create OpenGL ES 3.0 context. Falling back to OpenGL ES 2.0");
+ }
+ }
- // Create our EAGLContext, and if successful make it current and create our framebuffer.
- context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
-
- if (!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) {
+ // Create GL ES 2 context
+ if (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES2" || fallback_gl2) {
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
- gles3_available = false;
- if (!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) {
- [self release];
+ NSLog(@"Setting up an OpenGL ES 2.0 context.");
+ if (!context) {
+ NSLog(@"Failed to create OpenGL ES 2.0 context!");
return nil;
}
}
+ if (![EAGLContext setCurrentContext:context]) {
+ NSLog(@"Failed to set EAGLContext!");
+ return nil;
+ }
+ if (![self createFramebuffer]) {
+ NSLog(@"Failed to create frame buffer!");
+ return nil;
+ }
+
// Default the animation interval to 1/60th of a second.
animationInterval = 1.0 / 60.0;
return self;