Implement SDL_GL_SHARE_WITH_CURRENT_CONTEXT for iOS.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 12 Jul 2013 23:30:26 -0400
changeset 7423 dfe7ad02f008
parent 7422 172b0c6e51d6
child 7424 1644ff584b17
Implement SDL_GL_SHARE_WITH_CURRENT_CONTEXT for iOS. Fixes Bugzilla #1947.
src/video/uikit/SDL_uikitopengles.m
src/video/uikit/SDL_uikitopenglview.h
src/video/uikit/SDL_uikitopenglview.m
--- a/src/video/uikit/SDL_uikitopengles.m	Fri Jul 12 10:44:55 2013 -0700
+++ b/src/video/uikit/SDL_uikitopengles.m	Fri Jul 12 23:30:26 2013 -0400
@@ -104,6 +104,11 @@
     SDL_DisplayData *displaydata = display->driverdata;
     SDL_DisplayModeData *displaymodedata = display->current_mode.driverdata;
     UIWindow *uiwindow = data->uiwindow;
+    EAGLSharegroup *share_group = nil;
+
+    if (_this->gl_config.share_with_current_context) {
+        share_group = [((SDL_uikitopenglview *) SDL_GL_GetCurrentContext() sharegroup];
+    }
 
     /* construct our view, passing in SDL's OpenGL configuration data */
     CGRect frame;
@@ -121,7 +126,8 @@
                                     aBits: _this->gl_config.alpha_size
                                     depthBits: _this->gl_config.depth_size
                                     stencilBits: _this->gl_config.stencil_size
-                                    majorVersion: _this->gl_config.major_version];
+                                    majorVersion: _this->gl_config.major_version
+                                    shareGroup: share_group];
     if (!view) {
         return NULL;
     }
--- a/src/video/uikit/SDL_uikitopenglview.h	Fri Jul 12 10:44:55 2013 -0700
+++ b/src/video/uikit/SDL_uikitopenglview.h	Fri Jul 12 23:30:26 2013 -0400
@@ -67,7 +67,8 @@
     aBits:(int)aBits
     depthBits:(int)depthBits
     stencilBits:(int)stencilBits
-    majorVersion:(int)majorVersion;
+    majorVersion:(int)majorVersion
+    shareGroup:(EAGLSharegroup*)shareGroup;
 
 - (void)updateFrame;
 
--- a/src/video/uikit/SDL_uikitopenglview.m	Fri Jul 12 10:44:55 2013 -0700
+++ b/src/video/uikit/SDL_uikitopenglview.m	Fri Jul 12 23:30:26 2013 -0400
@@ -47,6 +47,7 @@
       depthBits:(int)depthBits
       stencilBits:(int)stencilBits
       majorVersion:(int)majorVersion
+      shareGroup:(EAGLSharegroup*)shareGroup
 {
     depthBufferFormat = 0;
 
@@ -71,9 +72,9 @@
                                         [NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil];
 
         if (majorVersion > 1) {
-            context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2];
+            context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup:shareGroup];
         } else {
-            context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
+            context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1 sharegroup:shareGroup];
         }
         if (!context || ![EAGLContext setCurrentContext:context]) {
             [self release];