diff options
author | dhewg | 2011-02-24 19:47:08 +0100 |
---|---|---|
committer | dhewg | 2011-02-24 20:24:58 +0100 |
commit | 273a324a7111608329eea4ee2e8c0c3d1636aa7c (patch) | |
tree | 6a4ef9274b4be67e5e25661b98addb764a497f09 /backends/platform | |
parent | 2e1497d835aad64dbe31bb89fb0f0dcb2596a1c4 (diff) | |
download | scummvm-rg350-273a324a7111608329eea4ee2e8c0c3d1636aa7c.tar.gz scummvm-rg350-273a324a7111608329eea4ee2e8c0c3d1636aa7c.tar.bz2 scummvm-rg350-273a324a7111608329eea4ee2e8c0c3d1636aa7c.zip |
SDL: Prevent unnecessary gfx manager hotswap
Diffstat (limited to 'backends/platform')
-rw-r--r-- | backends/platform/sdl/sdl.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index dc91bd9fe7..0bc0119a80 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -125,10 +125,11 @@ void OSystem_SDL::init() { if (_timerManager == 0) _timerManager = new SdlTimerManager(); - #ifdef USE_OPENGL - // Setup a list with both SDL and OpenGL graphics modes - setupGraphicsModes(); - #endif +#ifdef USE_OPENGL + // Setup a list with both SDL and OpenGL graphics modes + setupGraphicsModes(); + _graphicsMode = _sdlModesCount; +#endif } void OSystem_SDL::initBackend() { @@ -464,6 +465,7 @@ int OSystem_SDL::getDefaultGraphicsMode() const { bool OSystem_SDL::setGraphicsMode(int mode) { const OSystem::GraphicsMode *srcMode; int i; + // Check if mode is from SDL or OpenGL if (mode < _sdlModesCount) { srcMode = SdlGraphicsManager::supportedGraphicsModes(); @@ -472,28 +474,34 @@ bool OSystem_SDL::setGraphicsMode(int mode) { srcMode = OpenGLSdlGraphicsManager::supportedGraphicsModes(); i = _sdlModesCount; } + // Loop through modes while (srcMode->name) { if (i == mode) { // If the new mode and the current mode are not from the same graphics // manager, delete and create the new mode graphics manager if (_graphicsMode >= _sdlModesCount && mode < _sdlModesCount) { + debug(1, "switching to plain SDL graphics"); delete _graphicsManager; _graphicsManager = new SdlGraphicsManager(_eventSource); ((SdlGraphicsManager *)_graphicsManager)->initEventObserver(); _graphicsManager->beginGFXTransaction(); } else if (_graphicsMode < _sdlModesCount && mode >= _sdlModesCount) { + debug(1, "switching to OpenGL graphics"); delete _graphicsManager; _graphicsManager = new OpenGLSdlGraphicsManager(); ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); _graphicsManager->beginGFXTransaction(); } + _graphicsMode = mode; return _graphicsManager->setGraphicsMode(srcMode->id); } + i++; srcMode++; } + return false; } |