From 473a3f2e22f8c61f701c08cc8b98426fc609e2dc Mon Sep 17 00:00:00 2001 From: asvitkine <> Date: Sun, 21 Jan 2007 19:33:13 +0000 Subject: [PATCH] Fix for resolution switching corruption under SDL (Mac OS X). --- BasiliskII/src/SDL/video_sdl.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/BasiliskII/src/SDL/video_sdl.cpp b/BasiliskII/src/SDL/video_sdl.cpp index 812b4fd6..85688b95 100644 --- a/BasiliskII/src/SDL/video_sdl.cpp +++ b/BasiliskII/src/SDL/video_sdl.cpp @@ -719,6 +719,8 @@ void driver_base::restore_mouse_accel(void) * Windowed display driver */ +static int SDL_display_opened = FALSE; + // Open display driver_window::driver_window(SDL_monitor_desc &m) : driver_base(m), mouse_grabbed(false) @@ -730,11 +732,23 @@ driver_window::driver_window(SDL_monitor_desc &m) // Set absolute mouse mode ADBSetRelMouseMode(mouse_grabbed); + // This is ugly: + // If we're switching resolutions (ie, not setting it for the first time), + // there's a bug in SDL where the SDL_Surface created will not be properly + // setup. The solution is to SDL_Quit() before calling SDL_SetVideoMode for + // the second time (SDL_SetVideoMode will call SDL_Init() and all will be + // well). Without this, the video becomes corrupted (at least on Mac OS X), + // after the resolution switch (for the second and subsequent times). + if (SDL_display_opened) + SDL_Quit(); + // Create surface int depth = sdl_depth_of_video_depth(VIDEO_MODE_DEPTH); if ((s = SDL_SetVideoMode(width, height, depth, SDL_HWSURFACE)) == NULL) return; + SDL_display_opened = TRUE; + #ifdef ENABLE_VOSF use_vosf = true; // Allocate memory for frame buffer (SIZE is extended to page-boundary)