Fixed opengl context share groups on iOS. iOS-improvements
authorAlex Szpakowski <slime73@gmail.com>
Thu, 07 Aug 2014 00:44:16 -0300
branchiOS-improvements
changeset 9513 34d9391e7d3e
parent 9512 c9f61d1dac7b
child 9514 5b56ab9ff5fe
Fixed opengl context share groups on iOS.
src/video/uikit/SDL_uikitopengles.m
--- a/src/video/uikit/SDL_uikitopengles.m	Wed Aug 06 13:50:50 2014 -0300
+++ b/src/video/uikit/SDL_uikitopengles.m	Thu Aug 07 00:44:16 2014 -0300
@@ -129,8 +129,8 @@
         }
 
         if (_this->gl_config.share_with_current_context) {
-            SDL_uikitopenglview *view = (__bridge SDL_uikitopenglview *) SDL_GL_GetCurrentContext();
-            share_group = [view.context sharegroup];
+            EAGLContext *context = (__bridge EAGLContext *) SDL_GL_GetCurrentContext();
+            share_group = context.sharegroup;
         }
 
         /* construct our view, passing in SDL's OpenGL configuration data */
@@ -174,6 +174,7 @@
             SDL_SetKeyboardFocus(window);
         }
 
+        /* We return a +1'd context. The window's driverdata owns the view. */
         return (SDL_GLContext) CFBridgingRetain(context);
     }
 }
@@ -182,8 +183,9 @@
 UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
 {
     @autoreleasepool {
+        /* Transfer ownership the +1'd context to ARC. */
+        EAGLContext *eaglcontext = (EAGLContext *) CFBridgingRelease(context);
         SDL_Window *window;
-        EAGLContext *eaglcontext = (EAGLContext *) CFBridgingRelease(context);
 
         /* Find the view associated with this context */
         for (window = _this->windows; window; window = window->next) {