aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'backends/graphics')
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp51
-rw-r--r--backends/graphics/opengl/opengl-graphics.h10
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp62
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.h6
4 files changed, 67 insertions, 62 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
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index f76a100521..2d2a1bac7b 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -39,7 +39,7 @@ OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager(uint desktopWidth, uint deskt
#else
_lastVideoModeLoad(0),
#endif
- _graphicsScale(2), _stretchMode(STRETCH_FIT), _ignoreLoadVideoMode(false), _gotResize(false), _wantsFullScreen(false), _ignoreResizeEvents(0),
+ _graphicsScale(2), _ignoreLoadVideoMode(false), _gotResize(false), _wantsFullScreen(false), _ignoreResizeEvents(0),
_desiredFullscreenWidth(0), _desiredFullscreenHeight(0) {
// Setup OpenGL attributes for SDL
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
@@ -218,7 +218,6 @@ void OpenGLSdlGraphicsManager::deactivateManager() {
bool OpenGLSdlGraphicsManager::hasFeature(OSystem::Feature f) const {
switch (f) {
case OSystem::kFeatureFullscreenMode:
- case OSystem::kFeatureStretchMode:
case OSystem::kFeatureIconifyWindow:
return true;
@@ -267,54 +266,6 @@ bool OpenGLSdlGraphicsManager::getFeatureState(OSystem::Feature f) const {
}
}
-namespace {
-const OSystem::GraphicsMode sdlGlStretchModes[] = {
- {"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 *OpenGLSdlGraphicsManager::getSupportedStretchModes() const {
- return sdlGlStretchModes;
-}
-
-int OpenGLSdlGraphicsManager::getDefaultStretchMode() const {
- return STRETCH_FIT;
-}
-
-bool OpenGLSdlGraphicsManager::setStretchMode(int mode) {
- assert(getTransactionMode() != kTransactionNone);
-
- if (mode == _stretchMode)
- return true;
-
- // Check this is a valid mode
- const OSystem::GraphicsMode *sm = sdlGlStretchModes;
- 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 OpenGLSdlGraphicsManager::getStretchMode() const {
- return _stretchMode;
-}
-
void OpenGLSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
// HACK: This is stupid but the SurfaceSDL backend defaults to 2x. This
// assures that the launcher (which requests 320x200) has a reasonable
@@ -705,24 +656,25 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
// Ctrl+Alt+s cycles through stretch mode
int index = 0;
- const OSystem::GraphicsMode *sm = sdlGlStretchModes;
+ const OSystem::GraphicsMode *stretchModes = getSupportedStretchModes();
+ const OSystem::GraphicsMode *sm = stretchModes;
while (sm->name) {
- if (sm->id == _stretchMode)
+ if (sm->id == getStretchMode())
break;
sm++;
index++;
}
index++;
- if (!sdlGlStretchModes[index].name)
+ if (!stretchModes[index].name)
index = 0;
beginGFXTransaction();
- setStretchMode(sdlGlStretchModes[index].id);
+ setStretchMode(stretchModes[index].id);
endGFXTransaction();
#ifdef USE_OSD
Common::String message = Common::String::format("%s: %s",
_("Stretch mode"),
- _(sdlGlStretchModes[index].description)
+ _(stretchModes[index].description)
);
displayMessageOnOSD(message.c_str());
#endif
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h
index ff2277669e..2729a529fd 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -43,11 +43,6 @@ public:
virtual void setFeatureState(OSystem::Feature f, bool enable) override;
virtual bool getFeatureState(OSystem::Feature f) const override;
- 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 initSize(uint w, uint h, const Graphics::PixelFormat *format) override;
virtual void updateScreen() override;
@@ -84,7 +79,6 @@ private:
uint _lastRequestedWidth;
uint _lastRequestedHeight;
uint _graphicsScale;
- int _stretchMode;
bool _ignoreLoadVideoMode;
bool _gotResize;