Skip to content

Commit

Permalink
Mac: Immediately update current OpenGL context's shape.
Browse files Browse the repository at this point in the history
Previously we were postponing our -[NSOpenGLContext update] call to the next
SDL_GL_SwapWindow, even if the context was current on the current thread. This
changes it so that we will do the update immediately if it's the current
context.

If you're rendering on another thread, you need to call SDL_GL_SwapWindow once
after a resize event to ensure your drawable will produce non-garbage data.

Bug: https://bugzilla.libsdl.org/show_bug.cgi?id=2339
  • Loading branch information
jorgenpt committed Feb 25, 2014
1 parent 4c192bc commit 95f7e24
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/video/cocoa/SDL_cocoaopengl.m
Expand Up @@ -110,11 +110,19 @@ - (void)setWindow:(SDL_Window *)newWindow

if ([self view] != [windowdata->nswindow contentView]) {
[self setView:[windowdata->nswindow contentView]];
[self scheduleUpdate];
if (self == [NSOpenGLContext currentContext]) {
[self update];
} else {
[self scheduleUpdate];
}
}
} else {
[self clearDrawable];
[self scheduleUpdate];
if (self == [NSOpenGLContext currentContext]) {
[self update];
} else {
[self scheduleUpdate];
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -49,10 +49,15 @@ static void ConvertNSRect(NSRect *r)
static void
ScheduleContextUpdates(SDL_WindowData *data)
{
NSOpenGLContext *currentContext = [NSOpenGLContext currentContext];
NSMutableArray *contexts = data->nscontexts;
@synchronized (contexts) {
for (SDLOpenGLContext *context in contexts) {
[context scheduleUpdate];
if (context == currentContext) {
[context update];
} else {
[context scheduleUpdate];
}
}
}
}
Expand Down

0 comments on commit 95f7e24

Please sign in to comment.