fixed (reactivated) global animations (toons) for SDL 1.2 target
[rocksndiamonds.git] / src / libgame / sdl.c
index 8afeb35bb5bdba99bfdd49b583f8e6cf5c47b91e..a204e45ff13332cb09019531c551f78e3c7a2119 100644 (file)
@@ -558,8 +558,7 @@ static SDL_Surface *SDLCreateScreen(DrawBuffer **backbuffer,
        new_surface = SDL_CreateRGBSurface(0, width, height, 32, 0,0,0, 0);
 
        if (new_surface == NULL)
-         Error(ERR_WARN, "SDL_CreateRGBSurface() failed: %s",
-               SDL_GetError());
+         Error(ERR_WARN, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
       }
       else
       {
@@ -576,8 +575,41 @@ static SDL_Surface *SDLCreateScreen(DrawBuffer **backbuffer,
     Error(ERR_WARN, "SDL_CreateWindow() failed: %s", SDL_GetError());
   }
 
-#else
-  new_surface = SDL_SetVideoMode(width, height, video.depth, surface_flags);
+#else  // TARGET_SDL
+
+  if ((*backbuffer)->surface)
+  {
+    SDL_FreeSurface((*backbuffer)->surface);
+    (*backbuffer)->surface = NULL;
+  }
+
+  if (gfx.final_screen_bitmap == NULL)
+    gfx.final_screen_bitmap = CreateBitmapStruct();
+
+  gfx.final_screen_bitmap->width = width;
+  gfx.final_screen_bitmap->height = height;
+
+  gfx.final_screen_bitmap->surface =
+    SDL_SetVideoMode(width, height, video.depth, surface_flags);
+
+  if (gfx.final_screen_bitmap->surface != NULL)
+  {
+    new_surface =
+      SDL_CreateRGBSurface(surface_flags, width, height, video.depth, 0,0,0, 0);
+
+    if (new_surface == NULL)
+      Error(ERR_WARN, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
+
+#if 0
+    new_surface = gfx.final_screen_bitmap->surface;
+    gfx.final_screen_bitmap = NULL;
+#endif
+
+  }
+  else
+  {
+    Error(ERR_WARN, "SDL_SetVideoMode() failed: %s", SDL_GetError());
+  }
 #endif
 
 #if defined(TARGET_SDL2)
@@ -610,10 +642,7 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
 
     if (new_surface == NULL)
     {
-      /* switching display to fullscreen mode failed */
-      Error(ERR_WARN, "SDL_SetVideoMode() failed: %s", SDL_GetError());
-
-      /* do not try it again */
+      /* switching display to fullscreen mode failed -- do not try it again */
       video.fullscreen_available = FALSE;
 
       success = FALSE;
@@ -636,7 +665,6 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
     if (new_surface == NULL)
     {
       /* switching display to window mode failed -- should not happen */
-      Error(ERR_WARN, "SDL_SetVideoMode() failed: %s", SDL_GetError());
 
       success = FALSE;
     }