OPENGL: Handle aspect ratio correction as flag instead of having a special mode for it.
This partly fixes the OpenGL mode mess, but now OpenGL Normal and OpenGL Conserve will feature the same semantics when aspect ratio correction is enabled... That is still something to solve.
This commit is contained in:
parent
89f9c5a9c3
commit
6502e191b9
3 changed files with 27 additions and 42 deletions
|
@ -103,14 +103,8 @@ void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OSystem::kFeatureAspectRatioCorrection:
|
case OSystem::kFeatureAspectRatioCorrection:
|
||||||
// TODO: If we enable aspect ratio correction, we automatically set
|
_videoMode.aspectRatioCorrection = enable;
|
||||||
// the video mode to 4/3. That is quity messy, but since we have that
|
_transactionDetails.needRefresh = true;
|
||||||
// messy OpenGL mode use there's not much to do about it right now...
|
|
||||||
// Of course in case we disasble the aspect ratio correction, we
|
|
||||||
// might want to setup a different mode, but which one?
|
|
||||||
// Think of a way to get rid of this mess.
|
|
||||||
if (enable)
|
|
||||||
_videoMode.mode = OpenGL::GFX_4_3;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -124,7 +118,7 @@ bool OpenGLGraphicsManager::getFeatureState(OSystem::Feature f) {
|
||||||
return _videoMode.fullscreen;
|
return _videoMode.fullscreen;
|
||||||
|
|
||||||
case OSystem::kFeatureAspectRatioCorrection:
|
case OSystem::kFeatureAspectRatioCorrection:
|
||||||
return _videoMode.mode == OpenGL::GFX_4_3;
|
return _videoMode.aspectRatioCorrection;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -138,7 +132,6 @@ bool OpenGLGraphicsManager::getFeatureState(OSystem::Feature f) {
|
||||||
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
|
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
|
||||||
{"gl1", _s("OpenGL Normal"), OpenGL::GFX_NORMAL},
|
{"gl1", _s("OpenGL Normal"), OpenGL::GFX_NORMAL},
|
||||||
{"gl2", _s("OpenGL Conserve"), OpenGL::GFX_CONSERVE},
|
{"gl2", _s("OpenGL Conserve"), OpenGL::GFX_CONSERVE},
|
||||||
{"gl3", _s("OpenGL 4/3"), OpenGL::GFX_4_3},
|
|
||||||
{"gl4", _s("OpenGL Original"), OpenGL::GFX_ORIGINAL},
|
{"gl4", _s("OpenGL Original"), OpenGL::GFX_ORIGINAL},
|
||||||
{0, 0, 0}
|
{0, 0, 0}
|
||||||
};
|
};
|
||||||
|
@ -166,11 +159,10 @@ bool OpenGLGraphicsManager::setGraphicsMode(int mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case OpenGL::GFX_NORMAL:
|
case OpenGL::GFX_NORMAL:
|
||||||
case OpenGL::GFX_CONSERVE:
|
case OpenGL::GFX_CONSERVE:
|
||||||
case OpenGL::GFX_4_3:
|
|
||||||
case OpenGL::GFX_ORIGINAL:
|
case OpenGL::GFX_ORIGINAL:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
warning("unknown gfx mode %d", mode);
|
warning("Unknown gfx mode %d", mode);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,10 +1254,14 @@ void OpenGLGraphicsManager::toggleAntialiasing() {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint OpenGLGraphicsManager::getAspectRatio() {
|
uint OpenGLGraphicsManager::getAspectRatio() {
|
||||||
if (_videoMode.mode == OpenGL::GFX_NORMAL)
|
// In case we enable aspect ratio correction we force a 4/3 ratio.
|
||||||
return _videoMode.hardwareWidth * 10000 / _videoMode.hardwareHeight;
|
// TODO: This makes OpenGL Normal behave like OpenGL Conserve, when aspect
|
||||||
else if (_videoMode.mode == OpenGL::GFX_4_3)
|
// ratio correction is enabled, but it's better than the previous 4/3 mode
|
||||||
|
// mess at least...
|
||||||
|
if (_videoMode.aspectRatioCorrection)
|
||||||
return 13333;
|
return 13333;
|
||||||
|
else if (_videoMode.mode == OpenGL::GFX_NORMAL)
|
||||||
|
return _videoMode.hardwareWidth * 10000 / _videoMode.hardwareHeight;
|
||||||
else
|
else
|
||||||
return _videoMode.screenWidth * 10000 / _videoMode.screenHeight;
|
return _videoMode.screenWidth * 10000 / _videoMode.screenHeight;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,7 @@ namespace OpenGL {
|
||||||
enum {
|
enum {
|
||||||
GFX_NORMAL = 0,
|
GFX_NORMAL = 0,
|
||||||
GFX_CONSERVE = 1,
|
GFX_CONSERVE = 1,
|
||||||
GFX_4_3 = 2,
|
GFX_ORIGINAL = 2
|
||||||
GFX_ORIGINAL = 3
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -156,6 +155,7 @@ protected:
|
||||||
int mode;
|
int mode;
|
||||||
int scaleFactor;
|
int scaleFactor;
|
||||||
bool antialiasing;
|
bool antialiasing;
|
||||||
|
bool aspectRatioCorrection;
|
||||||
|
|
||||||
int screenWidth, screenHeight;
|
int screenWidth, screenHeight;
|
||||||
int overlayWidth, overlayHeight;
|
int overlayWidth, overlayHeight;
|
||||||
|
|
|
@ -295,10 +295,6 @@ bool OpenGLSdlGraphicsManager::setupFullscreenMode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenGLSdlGraphicsManager::loadGFXMode() {
|
bool OpenGLSdlGraphicsManager::loadGFXMode() {
|
||||||
// Force 4/3 if feature enabled
|
|
||||||
if (getFeatureState(OSystem::kFeatureAspectRatioCorrection))
|
|
||||||
_videoMode.mode = OpenGL::GFX_4_3;
|
|
||||||
|
|
||||||
// If the screen was resized, do not change its size
|
// If the screen was resized, do not change its size
|
||||||
if (!_screenResized) {
|
if (!_screenResized) {
|
||||||
const int scaleFactor = getScale();
|
const int scaleFactor = getScale();
|
||||||
|
@ -509,10 +505,19 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
|
||||||
// Ctrl-Alt-a switch between display modes
|
// Ctrl-Alt-a switch between display modes
|
||||||
if (event.kbd.keycode == 'a') {
|
if (event.kbd.keycode == 'a') {
|
||||||
beginGFXTransaction();
|
beginGFXTransaction();
|
||||||
switchDisplayMode(-1);
|
setFeatureState(OSystem::kFeatureAspectRatioCorrection, !getFeatureState(OSystem::kFeatureAspectRatioCorrection));
|
||||||
endGFXTransaction();
|
endGFXTransaction();
|
||||||
#ifdef USE_OSD
|
#ifdef USE_OSD
|
||||||
displayModeChangedMsg();
|
char buffer[128];
|
||||||
|
if (getFeatureState(OSystem::kFeatureAspectRatioCorrection))
|
||||||
|
sprintf(buffer, "Enabled aspect ratio correction\n%d x %d -> %d x %d",
|
||||||
|
_videoMode.screenWidth, _videoMode.screenHeight,
|
||||||
|
_hwscreen->w, _hwscreen->h);
|
||||||
|
else
|
||||||
|
sprintf(buffer, "Disabled aspect ratio correction\n%d x %d -> %d x %d",
|
||||||
|
_videoMode.screenWidth, _videoMode.screenHeight,
|
||||||
|
_hwscreen->w, _hwscreen->h);
|
||||||
|
displayMessageOnOSD(buffer);
|
||||||
#endif
|
#endif
|
||||||
internUpdateScreen();
|
internUpdateScreen();
|
||||||
return true;
|
return true;
|
||||||
|
@ -561,12 +566,12 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool isNormalNumber = (SDLK_1 <= sdlKey && sdlKey <= SDLK_4);
|
const bool isNormalNumber = (SDLK_1 <= sdlKey && sdlKey <= SDLK_3);
|
||||||
const bool isKeypadNumber = (SDLK_KP1 <= sdlKey && sdlKey <= SDLK_KP4);
|
const bool isKeypadNumber = (SDLK_KP1 <= sdlKey && sdlKey <= SDLK_KP3);
|
||||||
|
|
||||||
// Ctrl-Alt-<number key> will change the GFX mode
|
// Ctrl-Alt-<number key> will change the GFX mode
|
||||||
if (isNormalNumber || isKeypadNumber) {
|
if (isNormalNumber || isKeypadNumber) {
|
||||||
if (sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1) <= 4) {
|
if (sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1) <= 3) {
|
||||||
#ifdef USE_OSD
|
#ifdef USE_OSD
|
||||||
int lastMode = _videoMode.mode;
|
int lastMode = _videoMode.mode;
|
||||||
#endif
|
#endif
|
||||||
|
@ -576,10 +581,6 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
|
||||||
beginGFXTransaction();
|
beginGFXTransaction();
|
||||||
setGraphicsMode(sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1));
|
setGraphicsMode(sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1));
|
||||||
setScale(oldScale);
|
setScale(oldScale);
|
||||||
// TODO: We disable the aspect ratio correction here,
|
|
||||||
// we might switch to mode which ignores it...
|
|
||||||
// We should really fix this mess up.
|
|
||||||
setFeatureState(OSystem::kFeatureAspectRatioCorrection, false);
|
|
||||||
endGFXTransaction();
|
endGFXTransaction();
|
||||||
#ifdef USE_OSD
|
#ifdef USE_OSD
|
||||||
if (lastMode != _videoMode.mode)
|
if (lastMode != _videoMode.mode)
|
||||||
|
@ -597,18 +598,6 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
|
||||||
toggleFullScreen(-1);
|
toggleFullScreen(-1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ctrl-Shift-a switch backwards between display modes
|
|
||||||
if (event.kbd.keycode == 'a') {
|
|
||||||
beginGFXTransaction();
|
|
||||||
switchDisplayMode(-2);
|
|
||||||
endGFXTransaction();
|
|
||||||
#ifdef USE_OSD
|
|
||||||
displayModeChangedMsg();
|
|
||||||
#endif
|
|
||||||
internUpdateScreen();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Common::EVENT_KEYUP:
|
case Common::EVENT_KEYUP:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue