From 5719a3bb7fdaee6d0f0ca89f18fdfab8140f76a6 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Wed, 20 Nov 2024 23:43:47 +0000 Subject: [PATCH] BACKENDS: SDL: Never make window smaller in OpenGL mode when starting game Normally when using the OpenGL mode the window is not resized when starting a game, unless the game requires a window bigger than the current window size. However this was not the case if the engine called initSizeHint() with sizes smaller than the current window size, as in this case the window was forcibly resized to the bigger of those provided sizes. The initSizeHint() function was added for engines that use multiple resolutions to indicate when starting the engine that it may use multiple resolutions and thus may need a bigger window later than when the game starts. This allows getting the bigger size from the start and prevent window resize during gameplay. But this function was not meant to make the window smaller if the graphics backend request an even bigger size, which may be the case of the OpenGLSDL graphics backend as it tries to preserve the current window size. --- backends/graphics/sdl/sdl-graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index 0e5554bdbf8b..145e183e5098 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -353,10 +353,10 @@ bool SdlGraphicsManager::createOrUpdateWindow(int width, int height, const Uint3 const bool fullscreen = (flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP)) != 0; const bool maximized = (flags & SDL_WINDOW_MAXIMIZED); if (!fullscreen && !maximized) { - if (_hintedWidth) { + if (_hintedWidth > width) { width = _hintedWidth; } - if (_hintedHeight) { + if (_hintedHeight > height) { height = _hintedHeight; } }