diff src/video/cocoa/SDL_cocoaopengl.m @ 2178:114a541cfae2

Creating a context makes it current, per the documentation. Applied a variant of the multi-card OpenGL fix from SDL 1.2
author Sam Lantinga <slouken@libsdl.org>
date Thu, 12 Jul 2007 06:31:36 +0000
parents 81255f93dfcd
children 56cf872c723a
line wrap: on
line diff
--- a/src/video/cocoa/SDL_cocoaopengl.m	Thu Jul 12 05:32:07 2007 +0000
+++ b/src/video/cocoa/SDL_cocoaopengl.m	Thu Jul 12 06:31:36 2007 +0000
@@ -150,7 +150,7 @@
     SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
     NSOpenGLPixelFormatAttribute attr[32];
     NSOpenGLPixelFormat *fmt;
-    NSOpenGLContext *nscontext;
+    NSOpenGLContext *context;
     int i = 0;
 
     pool = [[NSAutoreleasePool alloc] init];
@@ -212,11 +212,11 @@
         return NULL;
     }
 
-    nscontext = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
+    context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
 
     [fmt release];
 
-    if (nscontext == nil) {
+    if (context == nil) {
         SDL_SetError ("Failed creating OpenGL context");
         [pool release];
         return NULL;
@@ -240,7 +240,7 @@
 
     {
         long cache_max = 64;
-        CGLContextObj ctx = [nscontext CGLContextObj];
+        CGLContextObj ctx = [context CGLContextObj];
         CGLSetParameter (ctx, GLI_SUBMIT_FUNC_CACHE_MAX, &cache_max);
         CGLSetParameter (ctx, GLI_ARRAY_FUNC_CACHE_MAX, &cache_max);
     }
@@ -248,7 +248,13 @@
     /* End Wisdom from Apple Engineer section. --ryan. */
 
     [pool release];
-    return nscontext;
+
+    if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
+        Cocoa_GL_DeleteContext(_this, context);
+        return NULL;
+    }
+
+    return context;
 }
 
 int