Implement SDL_GL_SHARE_WITH_CURRENT_CONTEXT for iOS.

Fixes Bugzilla #1947.
This commit is contained in:
Ryan C. Gordon 2013-07-12 23:30:26 -04:00
parent 06741a5761
commit 3d9b82d9f8
3 changed files with 12 additions and 4 deletions

View file

@ -104,6 +104,11 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
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 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
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;
}

View file

@ -67,7 +67,8 @@
aBits:(int)aBits
depthBits:(int)depthBits
stencilBits:(int)stencilBits
majorVersion:(int)majorVersion;
majorVersion:(int)majorVersion
shareGroup:(EAGLSharegroup*)shareGroup;
- (void)updateFrame;

View file

@ -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];