rnd-20100402-1-src
[rocksndiamonds.git] / src / libgame / sdl.c
index f751fe85be2a5e568b94c6929f3ea79fc5f3d0ee..4c484243934102774e2670d626f967495d87ef53 100644 (file)
@@ -140,6 +140,13 @@ void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window,
   fullscreen_xoffset = (fullscreen_width  - video.width)  / 2;
   fullscreen_yoffset = (fullscreen_height - video.height) / 2;
 
+#if 1
+  checked_free(video.fullscreen_modes);
+
+  video.fullscreen_modes = NULL;
+  video.fullscreen_mode_current = NULL;
+#endif
+
   /* get available hardware supported fullscreen modes */
   modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
 
@@ -228,7 +235,11 @@ void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window,
      should never be drawn to directly, it would do no harm nevertheless. */
 
   /* create additional (symbolic) buffer for double-buffering */
+#if 1
+  ReCreateBitmap(window, video.width, video.height, video.depth);
+#else
   *window = CreateBitmap(video.width, video.height, video.depth);
+#endif
 }
 
 boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
@@ -241,6 +252,10 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
   if (*backbuffer == NULL)
     *backbuffer = CreateBitmapStruct();
 
+  /* (real bitmap might be larger in fullscreen mode with video offsets) */
+  (*backbuffer)->width  = video.width;
+  (*backbuffer)->height = video.height;
+
   if (fullscreen && !video.fullscreen_enabled && video.fullscreen_available)
   {
     setFullscreenParameters(setup.fullscreen_mode);
@@ -292,11 +307,11 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
       (*backbuffer)->surface = new_surface;
 
       video.fullscreen_enabled = FALSE;
+
       success = TRUE;
     }
   }
 
-
 #if 1
   SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
 
@@ -423,6 +438,17 @@ void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height,
   int dst_x = x, dst_y = y;
   unsigned int time_last, time_current;
 
+  /* check if screen size has changed */
+  if (surface_source != NULL && (video.width  != surface_source->w ||
+                                video.height != surface_source->h))
+  {
+    SDL_FreeSurface(surface_source);
+    SDL_FreeSurface(surface_target);
+    SDL_FreeSurface(surface_black);
+
+    initialization_needed = TRUE;
+  }
+
   src_rect.x = src_x;
   src_rect.y = src_y;
   src_rect.w = width;