Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Implement SDL_GL_SHARE_WITH_CURRENT_CONTEXT for iOS.
Browse files Browse the repository at this point in the history
Fixes Bugzilla #1947.
  • Loading branch information
icculus committed Jul 13, 2013
1 parent 4a05d4c commit 77b3a8c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/video/uikit/SDL_uikitopengles.m
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/video/uikit/SDL_uikitopenglview.h
Expand Up @@ -67,7 +67,8 @@
aBits:(int)aBits
depthBits:(int)depthBits
stencilBits:(int)stencilBits
majorVersion:(int)majorVersion;
majorVersion:(int)majorVersion
shareGroup:(EAGLSharegroup*)shareGroup;

- (void)updateFrame;

Expand Down
5 changes: 3 additions & 2 deletions src/video/uikit/SDL_uikitopenglview.m
Expand Up @@ -47,6 +47,7 @@ - (id)initWithFrame:(CGRect)frame
depthBits:(int)depthBits
stencilBits:(int)stencilBits
majorVersion:(int)majorVersion
shareGroup:(EAGLSharegroup*)shareGroup
{
depthBufferFormat = 0;

Expand All @@ -71,9 +72,9 @@ - (id)initWithFrame:(CGRect)frame
[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];
Expand Down

0 comments on commit 77b3a8c

Please sign in to comment.