--- ../original/openttd-1.2.3/src/video/cocoa/fullscreen.mm 2012-10-31 19:38:49.000000000 -0200 +++ src/video/cocoa/fullscreen.mm 2012-11-11 14:26:09.000000000 -0200 @@ -153,7 +153,7 @@ CFDictionaryRef cur_mode; ///< current mode of the display CFDictionaryRef save_mode; ///< original mode of the display CGDirectPaletteRef palette; ///< palette of an 8-bit display - + NSOpenGLContext *context; ///< OpenGL context /* Gamma functions to try to hide the flash from a res switch * Fade the display from normal to black @@ -249,6 +249,27 @@ CSleep((uint32)(adjustment * 1000)); } + NSOpenGLContext* CreateGLContext(int w, int h, int bpp) { + NSOpenGLPixelFormatAttribute attrs[] = { + NSOpenGLPFAFullScreen, + NSOpenGLPFADoubleBuffer, + NSOpenGLPFADepthSize, bpp, + 0 + }; + NSOpenGLContext* myContext = nil; + NSOpenGLPixelFormat* pixFmt = [ [ NSOpenGLPixelFormat alloc ] initWithAttributes:attrs ]; + if (pixFmt != nil) { + myContext = [ [ NSOpenGLContext alloc ] initWithFormat:pixFmt + shareContext:NO]; + } + [ pixFmt release ]; + return myContext; + } + + void DestroyGLContext() { + free(this->context); + this->context = NULL; + } bool SetVideoMode(int w, int h, int bpp) { @@ -314,6 +335,9 @@ if (MacOSVersionIsAtLeast(10, 7, 0)) { this->window_buffer = NULL; this->window_pitch = NULL; + this->context = CreateGLContext(w, h, bpp); + [ this->context setFullScreen ]; + [ this->context makeCurrentContext ]; } else { #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7) this->window_buffer = CGDisplayBaseAddress(this->display_id); @@ -416,6 +440,8 @@ this->device_width = CGDisplayPixelsWide(this->display_id); this->device_height = CGDisplayPixelsHigh(this->display_id); + + DestroyGLContext(); } public: