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.
This commit is contained in:
parent
3e08c33c35
commit
c6ce1c8002
2 changed files with 32 additions and 20 deletions
|
@ -82,6 +82,7 @@ bool OpenGLGraphicsManager::hasFeature(OSystem::Feature f) {
|
||||||
switch (f) {
|
switch (f) {
|
||||||
case OSystem::kFeatureAspectRatioCorrection:
|
case OSystem::kFeatureAspectRatioCorrection:
|
||||||
case OSystem::kFeatureCursorPalette:
|
case OSystem::kFeatureCursorPalette:
|
||||||
|
case OSystem::kFeatureFilteringMode:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case OSystem::kFeatureOverlaySupportsAlpha:
|
case OSystem::kFeatureOverlaySupportsAlpha:
|
||||||
|
@ -99,6 +100,20 @@ void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
|
||||||
_currentState.aspectRatioCorrection = enable;
|
_currentState.aspectRatioCorrection = enable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OSystem::kFeatureFilteringMode:
|
||||||
|
assert(_transactionMode != kTransactionNone);
|
||||||
|
_currentState.filtering = enable;
|
||||||
|
|
||||||
|
if (_gameScreen) {
|
||||||
|
_gameScreen->enableLinearFiltering(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_cursor) {
|
||||||
|
_cursor->enableLinearFiltering(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case OSystem::kFeatureCursorPalette:
|
case OSystem::kFeatureCursorPalette:
|
||||||
_cursorPaletteEnabled = enable;
|
_cursorPaletteEnabled = enable;
|
||||||
updateCursorPalette();
|
updateCursorPalette();
|
||||||
|
@ -114,6 +129,9 @@ bool OpenGLGraphicsManager::getFeatureState(OSystem::Feature f) {
|
||||||
case OSystem::kFeatureAspectRatioCorrection:
|
case OSystem::kFeatureAspectRatioCorrection:
|
||||||
return _currentState.aspectRatioCorrection;
|
return _currentState.aspectRatioCorrection;
|
||||||
|
|
||||||
|
case OSystem::kFeatureFilteringMode:
|
||||||
|
return _currentState.filtering;
|
||||||
|
|
||||||
case OSystem::kFeatureCursorPalette:
|
case OSystem::kFeatureCursorPalette:
|
||||||
return _cursorPaletteEnabled;
|
return _cursorPaletteEnabled;
|
||||||
|
|
||||||
|
@ -125,8 +143,7 @@ bool OpenGLGraphicsManager::getFeatureState(OSystem::Feature f) {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const OSystem::GraphicsMode glGraphicsModes[] = {
|
const OSystem::GraphicsMode glGraphicsModes[] = {
|
||||||
{ "opengl_linear", _s("OpenGL"), GFX_LINEAR },
|
{ "opengl", _s("OpenGL"), GFX_OPENGL },
|
||||||
{ "opengl_nearest", _s("OpenGL (No filtering)"), GFX_NEAREST },
|
|
||||||
{ nullptr, nullptr, 0 }
|
{ nullptr, nullptr, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -137,25 +154,15 @@ const OSystem::GraphicsMode *OpenGLGraphicsManager::getSupportedGraphicsModes()
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenGLGraphicsManager::getDefaultGraphicsMode() const {
|
int OpenGLGraphicsManager::getDefaultGraphicsMode() const {
|
||||||
return GFX_LINEAR;
|
return GFX_OPENGL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenGLGraphicsManager::setGraphicsMode(int mode) {
|
bool OpenGLGraphicsManager::setGraphicsMode(int mode) {
|
||||||
assert(_transactionMode != kTransactionNone);
|
assert(_transactionMode != kTransactionNone);
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case GFX_LINEAR:
|
case GFX_OPENGL:
|
||||||
case GFX_NEAREST:
|
|
||||||
_currentState.graphicsMode = mode;
|
_currentState.graphicsMode = mode;
|
||||||
|
|
||||||
if (_gameScreen) {
|
|
||||||
_gameScreen->enableLinearFiltering(mode == GFX_LINEAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_cursor) {
|
|
||||||
_cursor->enableLinearFiltering(mode == GFX_LINEAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -250,6 +257,10 @@ OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() {
|
||||||
transactionError |= OSystem::kTransactionModeSwitchFailed;
|
transactionError |= OSystem::kTransactionModeSwitchFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_oldState.filtering != _currentState.filtering) {
|
||||||
|
transactionError |= OSystem::kTransactionFilteringFailed;
|
||||||
|
}
|
||||||
|
|
||||||
// Roll back to the old state.
|
// Roll back to the old state.
|
||||||
_currentState = _oldState;
|
_currentState = _oldState;
|
||||||
_transactionMode = kTransactionRollback;
|
_transactionMode = kTransactionRollback;
|
||||||
|
@ -286,7 +297,7 @@ OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_gameScreen->allocate(_currentState.gameWidth, _currentState.gameHeight);
|
_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.
|
// We fill the screen to all black or index 0 for CLUT8.
|
||||||
#ifdef USE_RGB_COLOR
|
#ifdef USE_RGB_COLOR
|
||||||
if (_currentState.gameFormat.bytesPerPixel == 1) {
|
if (_currentState.gameFormat.bytesPerPixel == 1) {
|
||||||
|
@ -660,7 +671,7 @@ void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int
|
||||||
}
|
}
|
||||||
_cursor = createSurface(textureFormat, true);
|
_cursor = createSurface(textureFormat, true);
|
||||||
assert(_cursor);
|
assert(_cursor);
|
||||||
_cursor->enableLinearFiltering(_currentState.graphicsMode == GFX_LINEAR);
|
_cursor->enableLinearFiltering(_currentState.filtering);
|
||||||
}
|
}
|
||||||
|
|
||||||
_cursorKeyColor = keycolor;
|
_cursorKeyColor = keycolor;
|
||||||
|
|
|
@ -50,8 +50,7 @@ class Shader;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
GFX_LINEAR = 0,
|
GFX_OPENGL = 0
|
||||||
GFX_NEAREST = 1
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpenGLGraphicsManager : virtual public GraphicsManager {
|
class OpenGLGraphicsManager : virtual public GraphicsManager {
|
||||||
|
@ -213,7 +212,7 @@ private:
|
||||||
#ifdef USE_RGB_COLOR
|
#ifdef USE_RGB_COLOR
|
||||||
gameFormat(),
|
gameFormat(),
|
||||||
#endif
|
#endif
|
||||||
aspectRatioCorrection(false), graphicsMode(GFX_LINEAR) {
|
aspectRatioCorrection(false), graphicsMode(GFX_OPENGL), filtering(true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool valid;
|
bool valid;
|
||||||
|
@ -224,6 +223,7 @@ private:
|
||||||
#endif
|
#endif
|
||||||
bool aspectRatioCorrection;
|
bool aspectRatioCorrection;
|
||||||
int graphicsMode;
|
int graphicsMode;
|
||||||
|
bool filtering;
|
||||||
|
|
||||||
bool operator==(const VideoState &right) {
|
bool operator==(const VideoState &right) {
|
||||||
return gameWidth == right.gameWidth && gameHeight == right.gameHeight
|
return gameWidth == right.gameWidth && gameHeight == right.gameHeight
|
||||||
|
@ -231,7 +231,8 @@ private:
|
||||||
&& gameFormat == right.gameFormat
|
&& gameFormat == right.gameFormat
|
||||||
#endif
|
#endif
|
||||||
&& aspectRatioCorrection == right.aspectRatioCorrection
|
&& aspectRatioCorrection == right.aspectRatioCorrection
|
||||||
&& graphicsMode == right.graphicsMode;
|
&& graphicsMode == right.graphicsMode
|
||||||
|
&& filtering == right.filtering;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const VideoState &right) {
|
bool operator!=(const VideoState &right) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue