From f897f5fd926aba02e4fef467001e0ef6c67d130c Mon Sep 17 00:00:00 2001 From: staphen Date: Mon, 6 Dec 2021 23:43:54 -0500 Subject: [PATCH] Resize PalSurface when resizing the game window --- Source/dx.cpp | 9 +++++++-- Source/dx.h | 1 + Source/utils/display.cpp | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/dx.cpp b/Source/dx.cpp index ee46febb7..96efe7982 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -92,8 +92,6 @@ void CreateBackBuffer() // time the global `palette` is changed. No need to do anything here as // the global `palette` doesn't have any colors set yet. #endif - - pal_surface_palette_version = 1; } void LockBufPriv() @@ -144,6 +142,7 @@ void dx_init() palette_init(); CreateBackBuffer(); + pal_surface_palette_version = 1; } void lock_buf(int idx) // NOLINT(misc-unused-parameters) @@ -219,6 +218,12 @@ void dx_reinit() force_redraw = 255; } +void dx_resize() +{ + CreateBackBuffer(); + force_redraw = 255; +} + void InitPalette() { Palette = SDLWrap::AllocPalette(); diff --git a/Source/dx.h b/Source/dx.h index 8b9bc8282..7e4d1e438 100644 --- a/Source/dx.h +++ b/Source/dx.h @@ -19,6 +19,7 @@ void lock_buf(int idx); void unlock_buf(int idx); void dx_cleanup(); void dx_reinit(); +void dx_resize(); void InitPalette(); void BltFast(SDL_Rect *srcRect, SDL_Rect *dstRect); void Blit(SDL_Surface *src, SDL_Rect *srcRect, SDL_Rect *dstRect); diff --git a/Source/utils/display.cpp b/Source/utils/display.cpp index 237c663bf..f247bd529 100644 --- a/Source/utils/display.cpp +++ b/Source/utils/display.cpp @@ -17,6 +17,7 @@ #include "controls/devices/joystick.h" #include "controls/devices/kbcontroller.h" #include "controls/game_controls.h" +#include "dx.h" #include "options.h" #include "utils/log.hpp" #include "utils/sdl_wrap.h" @@ -321,6 +322,7 @@ void ResizeWindow() #endif ReinitializeRenderer(); + dx_resize(); } SDL_Surface *GetOutputSurface()