From 3a2440c19315518904dc9b70d0509e4efbb162e5 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Wed, 27 Jul 2022 00:32:03 +0200 Subject: [PATCH] sdl_glimp: also recreate window on resolution change Window resolution can also change without calling vid_restart: it happens when the window failed to be created and a lower resolution is tried instead. --- src/engine/sys/sdl_glimp.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/engine/sys/sdl_glimp.cpp b/src/engine/sys/sdl_glimp.cpp index 4555e2a20a..f64b215b3b 100644 --- a/src/engine/sys/sdl_glimp.cpp +++ b/src/engine/sys/sdl_glimp.cpp @@ -785,20 +785,27 @@ static bool GLimp_CreateContext( const glConfiguration &configuration ) /* GLimp_DestroyWindowIfExists checks if window exists before destroying it so we can call GLimp_RecreateWindowWhenChange even -if no window is created yet. - -It is assumed width, height and other things like that are unchanged, -given vid_restart is called when changing those and then destroying -the window before calling this. */ +if no window is created yet. */ static bool GLimp_RecreateWindowWhenChange( const bool fullscreen, const bool bordered, const glConfiguration &configuration ) { + /* Those values doen't contribute to anything + when the window isn't created yet. */ static bool currentFullscreen = false; static bool currentBordered = false; + static int currentWidth = 0; + static int currentHeight = 0; static glConfiguration currentConfiguration = {}; if ( window == nullptr + /* We don't care if comparing default values + is wrong when the window isn't created yet as + the first thing we do is to overwrite them. */ + || glConfig.vidWidth != currentWidth + || glConfig.vidHeight != currentHeight || configuration != currentConfiguration ) { + currentWidth = glConfig.vidWidth; + currentHeight = glConfig.vidHeight; currentConfiguration = configuration; GLimp_DestroyWindowIfExists();