diff options
author | Thierry Crozat | 2016-10-12 22:36:16 +0100 |
---|---|---|
committer | Thierry Crozat | 2016-10-13 01:45:01 +0100 |
commit | c6ce1c800296d5a0f18bc101d34c25dc638a6714 (patch) | |
tree | 897f520fd53239f9d9534debe3e2536eb0f6891b /backends/graphics/opengl | |
parent | 3e08c33c352b3d28c75e818fe601904a26d03d0f (diff) | |
download | scummvm-rg350-c6ce1c800296d5a0f18bc101d34c25dc638a6714.tar.gz scummvm-rg350-c6ce1c800296d5a0f18bc101d34c25dc638a6714.tar.bz2 scummvm-rg350-c6ce1c800296d5a0f18bc101d34c25dc638a6714.zip |
OPENGL: Add support for filtering feature
This replaces the two graphics modes "OpenGL (No filtering)" and
"OpenGL". Now there is a single "OpenGL" mode and filtering is
controlled by the kFeatureFilteringMode.
Diffstat (limited to 'backends/graphics/opengl')
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.cpp | 43 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.h | 9 |
2 files changed, 32 insertions, 20 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 41f35e29eb..a0882347b5 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -82,6 +82,7 @@ bool OpenGLGraphicsManager::hasFeature(OSystem::Feature f) { switch (f) { case OSystem::kFeatureAspectRatioCorrection: case OSystem::kFeatureCursorPalette: + case OSystem::kFeatureFilteringMode: return true; case OSystem::kFeatureOverlaySupportsAlpha: @@ -99,6 +100,20 @@ void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { _currentState.aspectRatioCorrection = enable; break; + case OSystem::kFeatureFilteringMode: + assert(_transactionMode != kTransactionNone); + _currentState.filtering = enable; + + if (_gameScreen) { + _gameScreen->enableLinearFiltering(enable); + } + + if (_cursor) { + _cursor->enableLinearFiltering(enable); + } + + break; + case OSystem::kFeatureCursorPalette: _cursorPaletteEnabled = enable; updateCursorPalette(); @@ -114,6 +129,9 @@ bool OpenGLGraphicsManager::getFeatureState(OSystem::Feature f) { case OSystem::kFeatureAspectRatioCorrection: return _currentState.aspectRatioCorrection; + case OSystem::kFeatureFilteringMode: + return _currentState.filtering; + case OSystem::kFeatureCursorPalette: return _cursorPaletteEnabled; @@ -125,8 +143,7 @@ bool OpenGLGraphicsManager::getFeatureState(OSystem::Feature f) { namespace { const OSystem::GraphicsMode glGraphicsModes[] = { - { "opengl_linear", _s("OpenGL"), GFX_LINEAR }, - { "opengl_nearest", _s("OpenGL (No filtering)"), GFX_NEAREST }, + { "opengl", _s("OpenGL"), GFX_OPENGL }, { nullptr, nullptr, 0 } }; @@ -137,25 +154,15 @@ const OSystem::GraphicsMode *OpenGLGraphicsManager::getSupportedGraphicsModes() } int OpenGLGraphicsManager::getDefaultGraphicsMode() const { - return GFX_LINEAR; + return GFX_OPENGL; } bool OpenGLGraphicsManager::setGraphicsMode(int mode) { assert(_transactionMode != kTransactionNone); switch (mode) { - case GFX_LINEAR: - case GFX_NEAREST: + case GFX_OPENGL: _currentState.graphicsMode = mode; - - if (_gameScreen) { - _gameScreen->enableLinearFiltering(mode == GFX_LINEAR); - } - - if (_cursor) { - _cursor->enableLinearFiltering(mode == GFX_LINEAR); - } - return true; default: @@ -250,6 +257,10 @@ OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() { transactionError |= OSystem::kTransactionModeSwitchFailed; } + if (_oldState.filtering != _currentState.filtering) { + transactionError |= OSystem::kTransactionFilteringFailed; + } + // Roll back to the old state. _currentState = _oldState; _transactionMode = kTransactionRollback; @@ -286,7 +297,7 @@ OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() { } _gameScreen->allocate(_currentState.gameWidth, _currentState.gameHeight); - _gameScreen->enableLinearFiltering(_currentState.graphicsMode == GFX_LINEAR); + _gameScreen->enableLinearFiltering(_currentState.filtering); // We fill the screen to all black or index 0 for CLUT8. #ifdef USE_RGB_COLOR if (_currentState.gameFormat.bytesPerPixel == 1) { @@ -660,7 +671,7 @@ void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int } _cursor = createSurface(textureFormat, true); assert(_cursor); - _cursor->enableLinearFiltering(_currentState.graphicsMode == GFX_LINEAR); + _cursor->enableLinearFiltering(_currentState.filtering); } _cursorKeyColor = keycolor; diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index 7900f06fb7..01672f4f5c 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -50,8 +50,7 @@ class Shader; #endif enum { - GFX_LINEAR = 0, - GFX_NEAREST = 1 + GFX_OPENGL = 0 }; class OpenGLGraphicsManager : virtual public GraphicsManager { @@ -213,7 +212,7 @@ private: #ifdef USE_RGB_COLOR gameFormat(), #endif - aspectRatioCorrection(false), graphicsMode(GFX_LINEAR) { + aspectRatioCorrection(false), graphicsMode(GFX_OPENGL), filtering(true) { } bool valid; @@ -224,6 +223,7 @@ private: #endif bool aspectRatioCorrection; int graphicsMode; + bool filtering; bool operator==(const VideoState &right) { return gameWidth == right.gameWidth && gameHeight == right.gameHeight @@ -231,7 +231,8 @@ private: && gameFormat == right.gameFormat #endif && aspectRatioCorrection == right.aspectRatioCorrection - && graphicsMode == right.graphicsMode; + && graphicsMode == right.graphicsMode + && filtering == right.filtering; } bool operator!=(const VideoState &right) { |