aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorJohannes Schickel2013-10-21 01:10:09 +0200
committerJohannes Schickel2013-10-23 22:59:09 +0200
commitc323dedf3c5bc293e664d298b74be63658fc55bf (patch)
tree452029d9ed16c4da43a037f7c8b60b9fd638f64f /backends/platform
parentd34c9d5bcbbad9fdde59143d15d7e18bc82231c1 (diff)
downloadscummvm-rg350-c323dedf3c5bc293e664d298b74be63658fc55bf.tar.gz
scummvm-rg350-c323dedf3c5bc293e664d298b74be63658fc55bf.tar.bz2
scummvm-rg350-c323dedf3c5bc293e664d298b74be63658fc55bf.zip
SDL: Fix default graphics mode for switchable case.
The former code (incorrectly) assumed that the getDefaultGraphicsMode returns the index in the table returned by getSupportedGraphicsModes. Now the correct ID is searched and then used.
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/sdl/sdl.cpp18
-rw-r--r--backends/platform/sdl/sdl.h2
2 files changed, 18 insertions, 2 deletions
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 327dfe21b9..3272033df9 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -70,6 +70,8 @@ OSystem_SDL::OSystem_SDL()
_graphicsModes(),
_graphicsMode(0),
_firstGLMode(0),
+ _defaultSDLMode(0),
+ _defaultGLMode(0),
#endif
_inited(false),
_initedSDL(false),
@@ -547,9 +549,9 @@ int OSystem_SDL::getDefaultGraphicsMode() const {
} else {
// Return the default graphics mode from the current graphics manager
if (_graphicsMode < _firstGLMode)
- return _graphicsManager->getDefaultGraphicsMode();
+ return _defaultSDLMode;
else
- return _graphicsManager->getDefaultGraphicsMode() + _firstGLMode;
+ return _defaultGLMode;
}
}
@@ -650,27 +652,39 @@ int OSystem_SDL::getGraphicsMode() const {
void OSystem_SDL::setupGraphicsModes() {
_graphicsModes.clear();
_graphicsModeIds.clear();
+ _defaultSDLMode = _defaultGLMode = -1;
// Count the number of graphics modes
const OSystem::GraphicsMode *srcMode;
+ int defaultMode;
GraphicsManager *manager = new SurfaceSdlGraphicsManager(_eventSource);
srcMode = manager->getSupportedGraphicsModes();
+ defaultMode = manager->getDefaultGraphicsMode();
while (srcMode->name) {
+ if (defaultMode == srcMode->id) {
+ _defaultSDLMode = _graphicsModes.size();
+ }
_graphicsModes.push_back(*srcMode);
srcMode++;
}
delete manager;
+ assert(_defaultSDLMode != -1);
_firstGLMode = _graphicsModes.size();
manager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource);
srcMode = manager->getSupportedGraphicsModes();
+ defaultMode = manager->getDefaultGraphicsMode();
while (srcMode->name) {
+ if (defaultMode == srcMode->id) {
+ _defaultGLMode = _graphicsModes.size();
+ }
_graphicsModes.push_back(*srcMode);
srcMode++;
}
delete manager;
manager = nullptr;
+ assert(_defaultGLMode != -1);
// Set a null mode at the end
GraphicsMode nullMode;
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 6c7f371f2e..814cdd7c1b 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -115,6 +115,8 @@ protected:
Common::Array<int> _graphicsModeIds;
int _graphicsMode;
int _firstGLMode;
+ int _defaultSDLMode;
+ int _defaultGLMode;
/**
* Creates the merged graphics modes list