Skip to content

Commit

Permalink
BACKENDS: SDL: Never make window smaller in OpenGL mode when starting…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
criezy committed Nov 20, 2024
1 parent bc54695 commit 5719a3b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backends/graphics/sdl/sdl-graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 5719a3b

Please sign in to comment.