diff options
author | Johannes Schickel | 2015-12-08 13:21:05 +0100 |
---|---|---|
committer | Johannes Schickel | 2015-12-08 15:41:10 +0100 |
commit | 079037b73990b6107e59c7f1cd971c3a1cc221d1 (patch) | |
tree | 0858de87ee37f8bfd245d3dbb271acd0ca68ccc6 /backends/graphics/surfacesdl | |
parent | 7820bd5aed9d19fe09b910d1e6cc7ae1aa010631 (diff) | |
download | scummvm-rg350-079037b73990b6107e59c7f1cd971c3a1cc221d1.tar.gz scummvm-rg350-079037b73990b6107e59c7f1cd971c3a1cc221d1.tar.bz2 scummvm-rg350-079037b73990b6107e59c7f1cd971c3a1cc221d1.zip |
SDL: Prevent graphics stretching in fullscreen when using SDL2.
As a side effect we get better coordinates from mouse move events in
fullscreen, i.e. we do not get actual window coordinates but something close
to actual viewport coordinates. The easily noticable issue is that mouse
coordinates inside black bars are outside of the viewport. For example, the
x coordinate can get negative when there's a black bar at the left side.
Diffstat (limited to 'backends/graphics/surfacesdl')
-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(); |