aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/opengl
diff options
context:
space:
mode:
authorCameron Cawley2019-06-22 13:17:19 +0100
committerFilippos Karapetis2019-06-24 02:19:28 +0300
commit16f8c024d1dfba31e9f764818936384a429ac663 (patch)
tree5472dbec1944674de6fe9a5d4f6ee03dc0267e72 /backends/graphics/opengl
parentc57b2cc14888367ac09f67982e6571ba71202e2c (diff)
downloadscummvm-rg350-16f8c024d1dfba31e9f764818936384a429ac663.tar.gz
scummvm-rg350-16f8c024d1dfba31e9f764818936384a429ac663.tar.bz2
scummvm-rg350-16f8c024d1dfba31e9f764818936384a429ac663.zip
OPENGLSDL: Move stretch mode handling into OpenGLGraphicsManager
Diffstat (limited to 'backends/graphics/opengl')
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp51
-rw-r--r--backends/graphics/opengl/opengl-graphics.h10
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