aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorJohannes Schickel2015-05-16 16:54:13 +0200
committerJohannes Schickel2015-05-16 16:54:13 +0200
commit0654a45c05e2b5345fa373027f73df092564ddfc (patch)
tree8983f93e09288dca28f0838d03b8e14149f78dad /backends
parent3698ca8cf7e413687a65b72aebef8dc6804a585c (diff)
parent40e019efd45a02261a7dbc69ceaa9188d8c7a269 (diff)
downloadscummvm-rg350-0654a45c05e2b5345fa373027f73df092564ddfc.tar.gz
scummvm-rg350-0654a45c05e2b5345fa373027f73df092564ddfc.tar.bz2
scummvm-rg350-0654a45c05e2b5345fa373027f73df092564ddfc.zip
Merge pull request #596 from Templier/opengl_switch_crash
Fix crash and wrong fullscreen mode listing when switching to OpenGL
Diffstat (limited to 'backends')
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp2
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp12
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h3
3 files changed, 16 insertions, 1 deletions
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index c71b9c9219..53868b86d8 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -57,7 +57,7 @@ OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager(uint desktopWidth, uint deskt
}
#else
const SDL_Rect *const *availableModes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
- if (availableModes != (void *)-1) {
+ if (availableModes != NULL && availableModes != (void *)-1) {
for (;*availableModes; ++availableModes) {
const SDL_Rect *mode = *availableModes;
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index d08925349a..d74a6082e3 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -144,6 +144,7 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
#ifdef USE_SDL_DEBUG_FOCUSRECT
_enableFocusRectDebugCode(false), _enableFocusRect(false), _focusRect(),
#endif
+ _originalBitsPerPixel(0),
_transactionMode(kTransactionNone) {
// allocate palette storage
@@ -797,6 +798,12 @@ bool SurfaceSdlGraphicsManager::loadGFXMode() {
} else
#endif
{
+ // Save the original bpp to be able to restore the video mode on unload
+ if (_originalBitsPerPixel == 0) {
+ const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
+ _originalBitsPerPixel = videoInfo->vfmt->BitsPerPixel;
+ }
+
_hwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 16,
_videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
);
@@ -929,6 +936,11 @@ void SurfaceSdlGraphicsManager::unloadGFXMode() {
}
#endif
DestroyScalers();
+
+ // Reset video mode to original
+ // This will ensure that any new graphic manager will use the initial BPP when listing available modes
+ if (_originalBitsPerPixel != 0)
+ SDL_SetVideoMode(_videoMode.screenWidth, _videoMode.screenHeight, _originalBitsPerPixel, _videoMode.fullscreen ? (SDL_FULLSCREEN | SDL_SWSURFACE) : SDL_SWSURFACE);
}
bool SurfaceSdlGraphicsManager::hotswapGFXMode() {
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index 4ba15a304b..2431ce8664 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -236,6 +236,9 @@ protected:
};
VideoState _videoMode, _oldVideoMode;
+ // Original BPP to restore the video mode on unload
+ uint8 _originalBitsPerPixel;
+
/** Force full redraw on next updateScreen */
bool _forceFull;