浏览代码

fix SDL1 crash after screen resize

Wei Mingzhi 7 年之前
父节点
当前提交
d50cf814c9
共有 1 个文件被更改,包括 13 次插入4 次删除
  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
 }