Fixed SDL 1.2 fullscreen OpenGL on Mac OS X 10.7. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Wed, 10 Aug 2011 01:25:00 -0400
branchSDL-1.2
changeset 5606 cf638ceb1f2c
parent 5599 5d7e82c63e84
child 5607 01a3ec16d8d5
Fixed SDL 1.2 fullscreen OpenGL on Mac OS X 10.7. I'm not sure if there was a way to make CGLSetFullScreen() work, but the Cocoa path works fine on all Intel Macs. Please note that the "official" way to do fullscreen in 10.7 is just to make a window the size of the display mode, and OS X is now smart enough to recognize this as "fullscreen", but this helps earlier versions of the OS in any case.
src/video/quartz/SDL_QuartzVideo.m
--- a/src/video/quartz/SDL_QuartzVideo.m	Thu Aug 04 01:44:32 2011 -0400
+++ b/src/video/quartz/SDL_QuartzVideo.m	Wed Aug 10 01:25:00 2011 -0400
@@ -411,7 +411,9 @@
         if ( mode_flags & SDL_OPENGL ) {
         
             QZ_TearDownOpenGL (this);
+            #ifdef __powerpc__  /* we only use this for pre-10.3 compatibility. */
             CGLSetFullScreen (NULL);
+            #endif
         }
         if (to_desktop) {
             ShowMenuBar ();
@@ -529,9 +531,6 @@
         CGLError err;
         CGLContextObj ctx;
 
-        /* CGLSetFullScreen() will handle this for us. */
-        [ qz_window setLevel:NSNormalWindowLevel ];
-
         if ( ! QZ_SetupOpenGL (this, bpp, flags) ) {
             goto ERR_NO_GL;
         }
@@ -542,13 +541,22 @@
         [ [ qz_window contentView ] addSubview:window_view ];	
         [ window_view release ];
 
+#ifdef __powerpc__  /* there's a Cocoa API for this in 10.3 */
+        /* CGLSetFullScreen() will handle this for us. */
+        [ qz_window setLevel:NSNormalWindowLevel ];
+
         ctx = QZ_GetCGLContextObj (gl_context);
         err = CGLSetFullScreen (ctx);
-
         if (err) {
             SDL_SetError ("Error setting OpenGL fullscreen: %s", CGLErrorString(err));
             goto ERR_NO_GL;
         }
+#else
+        [ qz_window setLevel:CGShieldingWindowLevel() ];
+        [ gl_context setView:window_view ];
+        [ gl_context setFullScreen ];
+        [ gl_context update ];
+#endif
 
         [ gl_context makeCurrentContext];