diff options
Diffstat (limited to 'backends/graphics/opengl')
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.cpp | 51 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.h | 10 |
2 files changed, 60 insertions, 1 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index c603070751..83d2c86058 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -54,7 +54,7 @@ namespace OpenGL { OpenGLGraphicsManager::OpenGLGraphicsManager() : _currentState(), _oldState(), _transactionMode(kTransactionNone), _screenChangeID(1 << (sizeof(int) * 8 - 2)), - _pipeline(nullptr), + _pipeline(nullptr), _stretchMode(STRETCH_FIT), _defaultFormat(), _defaultFormatAlpha(), _gameScreen(nullptr), _gameScreenShakeOffset(0), _overlay(nullptr), _cursor(nullptr), @@ -88,6 +88,7 @@ bool OpenGLGraphicsManager::hasFeature(OSystem::Feature f) const { case OSystem::kFeatureAspectRatioCorrection: case OSystem::kFeatureCursorPalette: case OSystem::kFeatureFilteringMode: + case OSystem::kFeatureStretchMode: return true; case OSystem::kFeatureOverlaySupportsAlpha: @@ -234,6 +235,54 @@ Common::List<Graphics::PixelFormat> OpenGLGraphicsManager::getSupportedFormats() } #endif +namespace { +const OSystem::GraphicsMode glStretchModes[] = { + {"center", _s("Center"), STRETCH_CENTER}, + {"pixel-perfect", _s("Pixel-perfect scaling"), STRETCH_INTEGRAL}, + {"fit", _s("Fit to window"), STRETCH_FIT}, + {"stretch", _s("Stretch to window"), STRETCH_STRETCH}, + {nullptr, nullptr, 0} +}; + +} // End of anonymous namespace + +const OSystem::GraphicsMode *OpenGLGraphicsManager::getSupportedStretchModes() const { + return glStretchModes; +} + +int OpenGLGraphicsManager::getDefaultStretchMode() const { + return STRETCH_FIT; +} + +bool OpenGLGraphicsManager::setStretchMode(int mode) { + assert(getTransactionMode() != kTransactionNone); + + if (mode == _stretchMode) + return true; + + // Check this is a valid mode + const OSystem::GraphicsMode *sm = getSupportedStretchModes(); + bool found = false; + while (sm->name) { + if (sm->id == mode) { + found = true; + break; + } + sm++; + } + if (!found) { + warning("unknown stretch mode %d", mode); + return false; + } + + _stretchMode = mode; + return true; +} + +int OpenGLGraphicsManager::getStretchMode() const { + return _stretchMode; +} + void OpenGLGraphicsManager::beginGFXTransaction() { assert(_transactionMode == kTransactionNone); diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index 2e1df99534..0cf85ddfd6 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -75,6 +75,11 @@ public: virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const override; #endif + virtual const OSystem::GraphicsMode *getSupportedStretchModes() const override; + virtual int getDefaultStretchMode() const override; + virtual bool setStretchMode(int mode) override; + virtual int getStretchMode() const override; + virtual void beginGFXTransaction() override; virtual OSystem::TransactionError endGFXTransaction() override; @@ -229,6 +234,11 @@ private: */ int _screenChangeID; + /** + * The current stretch mode. + */ + int _stretchMode; + protected: /** * Set up the requested video mode. This takes parameters which describe |