diff options
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 9cb14525ee..01afc84b24 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -2380,7 +2380,8 @@ void SurfaceSdlGraphicsManager::deinitializeRenderer() { SDL_Surface *SurfaceSdlGraphicsManager::SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) { deinitializeRenderer(); - if (!_window->createWindow(width, height, (flags & SDL_FULLSCREEN) ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)) { + const bool isFullscreen = (flags & SDL_FULLSCREEN) != 0; + if (!_window->createWindow(width, height, isFullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)) { return nullptr; } @@ -2390,6 +2391,14 @@ SDL_Surface *SurfaceSdlGraphicsManager::SDL_SetVideoMode(int width, int height, return nullptr; } + // We set the logical renderer size to the requested resolution in + // fullscreen. This assures that SDL2 adds black bars if needed to prevent + // stretching. + if (isFullscreen && SDL_RenderSetLogicalSize(_renderer, width, height) < 0) { + deinitializeRenderer(); + return nullptr; + } + _screenTexture = SDL_CreateTexture(_renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, width, height); if (!_screenTexture) { deinitializeRenderer(); |