fixed re-initialization of textures after change of renderer
[rocksndiamonds.git] / src / libgame / sdl.c
index 996621532c1f895bba022559d670b750605536ae..d431aacf29c96c34d73b2a4db489d075608a5640 100644 (file)
@@ -144,9 +144,9 @@ static void UpdateScreen(SDL_Rect *rect)
 
 #else  // TARGET_SDL
   if (rect)
-    SDL_UpdateRects(backbuffer->surface, 1, rect);
+    SDL_UpdateRects(screen, 1, rect);
   else
-    SDL_UpdateRect(backbuffer->surface, 0, 0, 0, 0);
+    SDL_UpdateRect(screen, 0, 0, 0, 0);
 #endif
 }
 
@@ -349,6 +349,22 @@ void SDLCreateBitmapTextures(Bitmap *bitmap)
 #endif
 }
 
+void SDLFreeBitmapTextures(Bitmap *bitmap)
+{
+#if defined(TARGET_SDL2)
+  if (bitmap == NULL)
+    return;
+
+  if (bitmap->texture)
+    SDL_DestroyTexture(bitmap->texture);
+  if (bitmap->texture_masked)
+    SDL_DestroyTexture(bitmap->texture_masked);
+
+  bitmap->texture = NULL;
+  bitmap->texture_masked = NULL;
+#endif
+}
+
 void SDLInitVideoDisplay(void)
 {
 #if !defined(TARGET_SDL2)