From 6e02a103abea8e43784284f9a3181c1d90c2092e Mon Sep 17 00:00:00 2001 From: Hubert Maier Date: Mon, 9 Sep 2019 19:58:51 +0200 Subject: [PATCH] GRAPHICS: Do not use SDL_WINDOW_RESIZEABLE (#1574) SDL: Disallow resizing the window when support is not available The window can be resized when the game supports arbitrary resolutions or the platform allows rendering to a framebuffer. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 13 ++++++++++--- backends/graphics/openglsdl/openglsdl-graphics.h | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 68aac667c0d..f4d38159877 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -196,7 +196,8 @@ void OpenGLSdlGraphicsManager::createOrUpdateScreen() { } if (!createOrUpdateGLContext(_engineRequestedWidth, _engineRequestedHeight, - effectiveWidth, effectiveHeight, renderToFrameBuffer)) { + effectiveWidth, effectiveHeight, + renderToFrameBuffer, engineSupportsArbitraryResolutions)) { warning("SDL Error: %s", SDL_GetError()); g_system->quit(); } @@ -327,7 +328,8 @@ OpenGLSdlGraphicsManager::OpenGLPixelFormat::OpenGLPixelFormat(uint screenBytesP bool OpenGLSdlGraphicsManager::createOrUpdateGLContext(uint gameWidth, uint gameHeight, uint effectiveWidth, uint effectiveHeight, - bool renderToFramebuffer) { + bool renderToFramebuffer, + bool engineSupportsArbitraryResolutions) { // Build a list of OpenGL pixel formats usable by ResidualVM Common::Array pixelFormats; if (_antialiasing > 0 && !renderToFramebuffer) { @@ -379,7 +381,12 @@ bool OpenGLSdlGraphicsManager::createOrUpdateGLContext(uint gameWidth, uint game #endif #if SDL_VERSION_ATLEAST(2, 0, 0) - uint32 sdlflags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE; + uint32 sdlflags = SDL_WINDOW_OPENGL; + + if (renderToFramebuffer || engineSupportsArbitraryResolutions) { + sdlflags |= SDL_WINDOW_RESIZABLE; + } + if (_fullscreen) { // On Linux/X11, when toggling to fullscreen, the window manager saves // the window size to be able to restore it when going back to windowed mode. diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h index 75fd2057ebb..1731fec34ac 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.h +++ b/backends/graphics/openglsdl/openglsdl-graphics.h @@ -104,7 +104,8 @@ protected: * When unable to create a context with anti-aliasing this tries without. * When unable to create a context with the desired pixel depth this tries lower values. */ - bool createOrUpdateGLContext(uint gameWidth, uint gameHeight, uint effectiveWidth, uint effectiveHeight, bool renderToFramebuffer); + bool createOrUpdateGLContext(uint gameWidth, uint gameHeight, uint effectiveWidth, uint effectiveHeight, + bool renderToFramebuffer, bool engineSupportsArbitraryResolutions); void createOrUpdateScreen();