Browse Source

fix SDL1 crash after screen resize

Wei Mingzhi 7 years ago
parent
commit
d50cf814c9
1 changed files with 13 additions and 4 deletions
  1. 13 4
      video.c

+ 13 - 4
video.c

@@ -570,10 +570,17 @@ VIDEO_Resize(
 --*/
 {
 #if SDL_VERSION_ATLEAST(2,0,0)
-	if (gpTexture) SDL_DestroyTexture(gpTexture);
-	gpTexture = VIDEO_CreateTexture(w, h);
-	if (gpTexture == NULL)
-		TerminateOnError("Re-creating texture failed on window resize!\n");
+   if (gpTexture)
+   {
+      SDL_DestroyTexture(gpTexture);
+   }
+
+   gpTexture = VIDEO_CreateTexture(w, h);
+
+   if (gpTexture == NULL)
+   {
+      TerminateOnError("Re-creating texture failed on window resize!\n");
+   }
 #else
    DWORD                    flags;
    PAL_LARGE SDL_Color      palette[256];
@@ -605,6 +612,8 @@ VIDEO_Resize(
 
    SDL_SetPalette(gpScreenReal, SDL_PHYSPAL | SDL_LOGPAL, palette, 0, i);
    VIDEO_UpdateScreen(NULL);
+
+   gpPalette = gpScreenReal->format->palette;
 #endif
 }