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

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed bug 1958 - Cocoa SwapWindow doesn't swap the specified window
Ryan C. Gordon

We have this in Cocoa_GL_SwapWindow()...

    /* FIXME: Do we need to get the context for the window? */
    [[NSOpenGLContext currentContext] flushBuffer];

...which means if the current GL context is not the one in (window), we swap a different one than requested.

Right now, we don't store information about which context is assigned to which window, and the OS doesn't give you a way to retrieve it from an NSView. We would have to track this per-window during SDL_GL_MakeCurrent() (and SDL_GL_CreateContext) calls.
  • Loading branch information
slouken committed Jul 12, 2013
1 parent 105c5ea commit c794628
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/video/cocoa/SDL_cocoaopengl.m
Expand Up @@ -212,6 +212,7 @@
SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata;
NSOpenGLContext *nscontext = (NSOpenGLContext *)context;

windowdata->nscontext = nscontext;
if ([nscontext view] != [windowdata->nswindow contentView]) {
[nscontext setView:[windowdata->nswindow contentView]];
[nscontext update];
Expand Down Expand Up @@ -272,12 +273,12 @@
Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
{
NSAutoreleasePool *pool;
NSOpenGLContext *nscontext;
SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata;
NSOpenGLContext *nscontext = windowdata->nscontext;

pool = [[NSAutoreleasePool alloc] init];

/* FIXME: Do we need to get the context for the window? */
[[NSOpenGLContext currentContext] flushBuffer];
[nscontext flushBuffer];

[pool release];
}
Expand Down
1 change: 1 addition & 0 deletions src/video/cocoa/SDL_cocoawindow.h
Expand Up @@ -86,6 +86,7 @@ struct SDL_WindowData
{
SDL_Window *window;
NSWindow *nswindow;
NSOpenGLContext *nscontext;
SDL_bool created;
Cocoa_WindowListener *listener;
struct SDL_VideoData *videodata;
Expand Down

0 comments on commit c794628

Please sign in to comment.