aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp15
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h16
2 files changed, 24 insertions, 7 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 2b9d3aa100..21345515bc 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -127,7 +127,8 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
#if SDL_VERSION_ATLEAST(2, 0, 0)
_renderer(nullptr), _screenTexture(nullptr),
_viewport(), _windowWidth(1), _windowHeight(1),
-#else
+#endif
+#if defined(WIN32) && !SDL_VERSION_ATLEAST(2, 0, 0)
_originalBitsPerPixel(0),
#endif
_screen(0), _tmpscreen(0),
@@ -801,8 +802,9 @@ bool SurfaceSdlGraphicsManager::loadGFXMode() {
} else
#endif
{
- // Save the original bpp to be able to restore the video mode on unload
-#if !SDL_VERSION_ATLEAST(2, 0, 0)
+#if defined(WIN32) && !SDL_VERSION_ATLEAST(2, 0, 0)
+ // Save the original bpp to be able to restore the video mode on
+ // unload. See _originalBitsPerPixel documentation.
if (_originalBitsPerPixel == 0) {
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
_originalBitsPerPixel = videoInfo->vfmt->BitsPerPixel;
@@ -947,9 +949,10 @@ void SurfaceSdlGraphicsManager::unloadGFXMode() {
#endif
DestroyScalers();
-#if !SDL_VERSION_ATLEAST(2, 0, 0)
- // Reset video mode to original
- // This will ensure that any new graphic manager will use the initial BPP when listing available modes
+#if defined(WIN32) && !SDL_VERSION_ATLEAST(2, 0, 0)
+ // Reset video mode to original.
+ // This will ensure that any new graphic manager will use the initial BPP
+ // when listing available modes. See _originalBitsPerPixel documentation.
if (_originalBitsPerPixel != 0)
SDL_SetVideoMode(_videoMode.screenWidth, _videoMode.screenHeight, _originalBitsPerPixel, _videoMode.fullscreen ? (SDL_FULLSCREEN | SDL_SWSURFACE) : SDL_SWSURFACE);
#endif
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index c4f7346525..25d6ff041c 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -251,8 +251,22 @@ protected:
};
VideoState _videoMode, _oldVideoMode;
- // Original BPP to restore the video mode on unload
+#if defined(WIN32) && !SDL_VERSION_ATLEAST(2, 0, 0)
+ /**
+ * Original BPP to restore the video mode on unload.
+ *
+ * This is required to make listing video modes for the OpenGL output work
+ * on Windows 8+. On these systems OpenGL modes are only available for
+ * 32bit formats. However, we setup a 16bit format and thus mode listings
+ * for OpenGL will return an empty list afterwards.
+ *
+ * In theory we might require this behavior on non-Win32 platforms too.
+ * However, SDL sometimes gives us invalid pixel formats for X11 outputs
+ * causing crashes when trying to setup the original pixel format.
+ * See bug #7038 "IRIX: X BadMatch when trying to start any 640x480 game".
+ */
uint8 _originalBitsPerPixel;
+#endif
/** Force full redraw on next updateScreen */
bool _forceFull;