[Scummvm-git-logs] scummvm branch-2-9 -> c08ace2b72ca588d132747a27e867e9a54010022

criezy noreply at scummvm.org
Fri Nov 22 00:21:11 UTC 2024


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
677712e05a BACKENDS: SDL: Never make window smaller in OpenGL mode when starting game
c08ace2b72 BACKENDS: SDL: Fix default scale factor used in initSizeHint


Commit: 677712e05a4fedc21b507a05f197ba81dc2b96fb
    https://github.com/scummvm/scummvm/commit/677712e05a4fedc21b507a05f197ba81dc2b96fb
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2024-11-22T00:20:52Z

Commit Message:
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.

Changed paths:
    backends/graphics/sdl/sdl-graphics.cpp


diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index 0e5554bdbf8..145e183e509 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;
 			}
 		}


Commit: c08ace2b72ca588d132747a27e867e9a54010022
    https://github.com/scummvm/scummvm/commit/c08ace2b72ca588d132747a27e867e9a54010022
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2024-11-22T00:20:52Z

Commit Message:
BACKENDS: SDL: Fix default scale factor used in initSizeHint

The "scale_factor" setting can be -1, which means the default. But
instead it was hardcoded to 1, which is wrong for the SurfaceSDL
graphics mode where the default is 2.

Changed paths:
    backends/graphics/sdl/sdl-graphics.cpp


diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index 145e183e509..8de597a29e4 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -166,10 +166,14 @@ void SdlGraphicsManager::initSizeHint(const Graphics::ModeList &modes) {
 #if SDL_VERSION_ATLEAST(2, 0, 0)
 	const bool useDefault = defaultGraphicsModeConfig();
 
+	// This gets called from engine before they call initGraphics(), which means we cannot use getScaleFactor()
+	// because the scale factor in the backend has not yet been updated to use the game settings. So directly
+	// read the game settings. This may be -1, which means we want to use the default. Fortunately runGame()
+	// in main.cpp sets the gaphics mode (OpenGL or SurfaceSDL) before starting the engine. So we already have
+	// the correct graphics manager and we can call getDefaultScaleFactor() here.
 	int scale = ConfMan.getInt("scale_factor");
 	if (scale == -1) {
-		warning("Unknown scaler; defaulting to 1");
-		scale = 1;
+		scale = getDefaultScaleFactor();
 	}
 
 	int16 bestWidth = 0, bestHeight = 0;




More information about the Scummvm-git-logs mailing list