summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Green <samuel.green@instacart.com>2019-03-14 15:14:20 -0700
committerSam Green <samuel.green@instacart.com>2019-03-14 16:31:54 -0700
commit440706814a8a8c43ad4608e6c1cfc6580ce5a5c1 (patch)
tree59e29c5f74725438f0e4928035e2fa70a3ad0a24
parent775e74e0d41daa9cf3679c2e215f4ef46eee9cbc (diff)
Add logging around opengl es context creation. Ensure we can access project settings prior to creating our gl es context, so we can properly determine which driver to use.
-rw-r--r--platform/iphone/app_delegate.mm18
-rw-r--r--platform/iphone/gl_view.mm26
2 files changed, 24 insertions, 20 deletions
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index d160553050..64405bfa5b 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -615,18 +615,6 @@ static int frame_count = 0;
// Create a full-screen window
window = [[UIWindow alloc] initWithFrame:rect];
- // window.autoresizesSubviews = YES;
- //[window setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
- // UIViewAutoresizingFlexibleWidth];
-
- // Create the OpenGL ES view and add it to the window
- GLView *glView = [[GLView alloc] initWithFrame:rect];
- printf("glview is %p\n", glView);
- //[window addSubview:glView];
- glView.delegate = self;
- // glView.autoresizesSubviews = YES;
- //[glView setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
- // UIViewAutoresizingFlexibleWidth];
OS::VideoMode vm = _get_video_mode();
@@ -641,6 +629,12 @@ static int frame_count = 0;
return FALSE;
};
+ // WARNING: We must *always* create the GLView after we have constructed the
+ // OS with iphone_main. This allows the GLView to access project settings so
+ // it can properly initialize the OpenGL context
+ GLView *glView = [[GLView alloc] initWithFrame:rect];
+ glView.delegate = self;
+
view_controller = [[ViewController alloc] init];
view_controller.view = glView;
window.rootViewController = view_controller;
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index 6f4d0ddb57..004f53b280 100644
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -285,16 +285,26 @@ static void clear_touches() {
kEAGLDrawablePropertyColorFormat,
nil];
- // 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 a 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 context. Based on Project Settings \"rendering/quality/driver/driver_name\"");
+ } else if (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES2") {
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
gles3_available = false;
- if (!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) {
- [self release];
- return nil;
- }
+ 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 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.