Add EAGLContext for the fallback case

This commit is contained in:
Sam Green 2019-03-14 18:36:33 -07:00
parent 440706814a
commit 4946335d3d
1 changed files with 18 additions and 10 deletions

View File

@ -284,20 +284,28 @@ static void clear_touches() {
kEAGLColorFormatRGBA8, kEAGLColorFormatRGBA8,
kEAGLDrawablePropertyColorFormat, kEAGLDrawablePropertyColorFormat,
nil]; nil];
bool fallback_gl2 = false;
// Create a context based on the gl driver from project settings // Create a GL ES 3 context based on the gl driver from project settings
if (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES3") { if (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES3") {
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
NSLog(@"Setting up an OpenGL ES 3 context. Based on Project Settings \"rendering/quality/driver/driver_name\""); NSLog(@"Setting up an OpenGL ES 3.0 context. Based on Project Settings \"rendering/quality/driver/driver_name\"");
} else if (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES2") { 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 GL ES 2 context
if (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES2" || fallback_gl2) {
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
gles3_available = false; NSLog(@"Setting up an OpenGL ES 2.0 context.");
NSLog(@"Setting up an OpenGL ES 2 context. Based on Project Settings \"rendering/quality/driver/driver_name\""); if (!context) {
} NSLog(@"Failed to create OpenGL ES 2.0 context!");
if (!context) { return nil;
NSLog(@"Failed to create OpenGL ES context!"); }
return nil;
} }
if (![EAGLContext setCurrentContext:context]) { if (![EAGLContext setCurrentContext:context]) {
NSLog(@"Failed to set EAGLContext!"); NSLog(@"Failed to set EAGLContext!");
return nil; return nil;