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.
This commit is contained in:
Hubert Maier 2019-09-09 19:58:51 +02:00 committed by Bastien Bouclet
parent 673a4393c6
commit 6e02a103ab
2 changed files with 12 additions and 4 deletions

View file

@ -196,7 +196,8 @@ void OpenGLSdlGraphicsManager::createOrUpdateScreen() {
} }
if (!createOrUpdateGLContext(_engineRequestedWidth, _engineRequestedHeight, if (!createOrUpdateGLContext(_engineRequestedWidth, _engineRequestedHeight,
effectiveWidth, effectiveHeight, renderToFrameBuffer)) { effectiveWidth, effectiveHeight,
renderToFrameBuffer, engineSupportsArbitraryResolutions)) {
warning("SDL Error: %s", SDL_GetError()); warning("SDL Error: %s", SDL_GetError());
g_system->quit(); g_system->quit();
} }
@ -327,7 +328,8 @@ OpenGLSdlGraphicsManager::OpenGLPixelFormat::OpenGLPixelFormat(uint screenBytesP
bool OpenGLSdlGraphicsManager::createOrUpdateGLContext(uint gameWidth, uint gameHeight, bool OpenGLSdlGraphicsManager::createOrUpdateGLContext(uint gameWidth, uint gameHeight,
uint effectiveWidth, uint effectiveHeight, uint effectiveWidth, uint effectiveHeight,
bool renderToFramebuffer) { bool renderToFramebuffer,
bool engineSupportsArbitraryResolutions) {
// Build a list of OpenGL pixel formats usable by ResidualVM // Build a list of OpenGL pixel formats usable by ResidualVM
Common::Array<OpenGLPixelFormat> pixelFormats; Common::Array<OpenGLPixelFormat> pixelFormats;
if (_antialiasing > 0 && !renderToFramebuffer) { if (_antialiasing > 0 && !renderToFramebuffer) {
@ -379,7 +381,12 @@ bool OpenGLSdlGraphicsManager::createOrUpdateGLContext(uint gameWidth, uint game
#endif #endif
#if SDL_VERSION_ATLEAST(2, 0, 0) #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) { if (_fullscreen) {
// On Linux/X11, when toggling to fullscreen, the window manager saves // 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. // the window size to be able to restore it when going back to windowed mode.

View file

@ -104,7 +104,8 @@ protected:
* When unable to create a context with anti-aliasing this tries without. * 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. * 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(); void createOrUpdateScreen();