From 9daa1c7f9359ca2467e9067b2f31021fdb7e0981 Mon Sep 17 00:00:00 2001 From: Alejandro Marzini Date: Fri, 30 Jul 2010 03:06:57 +0000 Subject: OSYSTEM: Add resetGraphicsScale() method. This fixes a hack for resetting the graphics scale to x1 when starting games that have a large screen size. The SDL graphics manager should now scale back to x1 without changing the current scaler in use, as well as the OpenGL graphics manager. svn-id: r51492 --- backends/base-backend.cpp | 6 ++++++ backends/base-backend.h | 2 ++ backends/graphics/graphics.h | 1 + backends/graphics/opengl/opengl-graphics.cpp | 4 ++++ backends/graphics/opengl/opengl-graphics.h | 1 + backends/graphics/sdl/sdl-graphics.cpp | 4 ++++ backends/graphics/sdl/sdl-graphics.h | 1 + backends/modular-backend.cpp | 4 ++++ backends/modular-backend.h | 1 + common/system.h | 7 +++++++ engines/engine.cpp | 5 +---- 11 files changed, 32 insertions(+), 4 deletions(-) diff --git a/backends/base-backend.cpp b/backends/base-backend.cpp index 86d2e8c2c8..aa08e94c32 100644 --- a/backends/base-backend.cpp +++ b/backends/base-backend.cpp @@ -92,3 +92,9 @@ AudioCDManager *BaseBackend::getAudioCDManager() { s_audiocdManager = new DefaultAudioCDManager(); return (AudioCDManager *)s_audiocdManager; } + +void BaseBackend::resetGraphicsScale() { + // As a hack, we use 0 here. Backends should override this method + // and provide their own. + setGraphicsMode(0); +} diff --git a/backends/base-backend.h b/backends/base-backend.h index d7c3579eb0..bcacde9aad 100644 --- a/backends/base-backend.h +++ b/backends/base-backend.h @@ -40,6 +40,8 @@ public: virtual Common::WriteStream *createConfigWriteStream(); virtual AudioCDManager *getAudioCDManager(); + + virtual void resetGraphicsScale(); }; diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index 0a123d2cb4..d2ce6534e1 100644 --- a/backends/graphics/graphics.h +++ b/backends/graphics/graphics.h @@ -45,6 +45,7 @@ public: virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const = 0; virtual int getDefaultGraphicsMode() const = 0; virtual bool setGraphicsMode(int mode) = 0; + virtual void resetGraphicsScale() = 0; virtual int getGraphicsMode() const = 0; #ifdef USE_RGB_COLOR virtual Graphics::PixelFormat getScreenFormat() const = 0; diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 0526a791ee..11ac5f0fce 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -168,6 +168,10 @@ int OpenGLGraphicsManager::getGraphicsMode() const { return _videoMode.mode; } +void OpenGLGraphicsManager::resetGraphicsScale() { + setScale(1); +} + #ifdef USE_RGB_COLOR Graphics::PixelFormat OpenGLGraphicsManager::getScreenFormat() const { diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index ee14df836e..88bcfe564b 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -59,6 +59,7 @@ public: virtual int getDefaultGraphicsMode() const; virtual bool setGraphicsMode(int mode); virtual int getGraphicsMode() const; + virtual void resetGraphicsScale(); #ifdef USE_RGB_COLOR virtual Graphics::PixelFormat getScreenFormat() const; virtual Common::List getSupportedFormats() const = 0; diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index 2d61cec185..a6cf5c54dd 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -248,6 +248,10 @@ int SdlGraphicsManager::getDefaultGraphicsMode() const { return GFX_DOUBLESIZE; } +void SdlGraphicsManager::resetGraphicsScale() { + setGraphicsMode(s_gfxModeSwitchTable[_scalerType][0]); +} + void SdlGraphicsManager::beginGFXTransaction() { assert(_transactionMode == kTransactionNone); diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h index 52c30f5e00..e2ad4b525d 100644 --- a/backends/graphics/sdl/sdl-graphics.h +++ b/backends/graphics/sdl/sdl-graphics.h @@ -86,6 +86,7 @@ public: virtual int getDefaultGraphicsMode() const; virtual bool setGraphicsMode(int mode); virtual int getGraphicsMode() const; + virtual void resetGraphicsScale(); #ifdef USE_RGB_COLOR virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } virtual Common::List getSupportedFormats() const; diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index e7d0764c11..be488f0190 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -91,6 +91,10 @@ int ModularBackend::getGraphicsMode() const { return _graphicsManager->getGraphicsMode(); } +void ModularBackend::resetGraphicsScale() { + _graphicsManager->resetGraphicsScale(); +} + #ifdef USE_RGB_COLOR Graphics::PixelFormat ModularBackend::getScreenFormat() const { diff --git a/backends/modular-backend.h b/backends/modular-backend.h index 63e13059cb..b7920d9d71 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -74,6 +74,7 @@ public: virtual int getDefaultGraphicsMode() const; virtual bool setGraphicsMode(int mode); virtual int getGraphicsMode() const; + virtual void resetGraphicsScale(); #ifdef USE_RGB_COLOR virtual Graphics::PixelFormat getScreenFormat() const; virtual Common::List getSupportedFormats() const; diff --git a/common/system.h b/common/system.h index 6c8d6108a4..a11adb4134 100644 --- a/common/system.h +++ b/common/system.h @@ -356,6 +356,13 @@ public: */ virtual int getGraphicsMode() const = 0; + /** + * Sets the graphics scale factor to x1. Games with large screen sizes + * reset the scale to x1 so the screen will not be too big when starting + * the game. + */ + virtual void resetGraphicsScale() = 0; + #ifdef USE_RGB_COLOR /** * Determine the pixel format currently in use for screen rendering. diff --git a/engines/engine.cpp b/engines/engine.cpp index 84fc0bbe4e..3c85220931 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -154,10 +154,7 @@ void initCommonGFX(bool defaultTo1XScaler) { // See if the game should default to 1x scaler if (useDefaultGraphicsMode && defaultTo1XScaler) { - // FIXME: As a hack, we use "1x" here. Would be nicer to use - // getDefaultGraphicsMode() instead, but right now, we do not specify - // whether that is a 1x scaler or not... - g_system->setGraphicsMode("1x"); + g_system->resetGraphicsScale(); } else { // Override global scaler with any game-specific define if (ConfMan.hasKey("gfx_mode")) { -- cgit v1.2.3