OPENGL: Add 5/3 and 5/4 aspect ratio corrections.

svn-id: r51806
This commit is contained in:
Alejandro Marzini 2010-08-06 21:39:54 +00:00
parent 4e890f8d74
commit 7b898648bc
3 changed files with 24 additions and 7 deletions

View File

@ -75,6 +75,10 @@ OpenGLGraphicsManager::OpenGLGraphicsManager()
_desiredAspectRatio = kAspectRatio16_9;
else if (!scumm_stricmp(desiredAspectRatio.c_str(), "16/10"))
_desiredAspectRatio = kAspectRatio16_10;
else if (!scumm_stricmp(desiredAspectRatio.c_str(), "5/3"))
_desiredAspectRatio = kAspectRatio5_3;
else if (!scumm_stricmp(desiredAspectRatio.c_str(), "5/4"))
_desiredAspectRatio = kAspectRatio5_4;
#endif
}
@ -1187,7 +1191,7 @@ void OpenGLGraphicsManager::setAspectRatioCorrection(int ratio) {
if (ratio == -1)
// If -1, switch to next mode
#ifdef USE_ALL_ASR
_videoMode.aspectRatioCorrection = (_videoMode.aspectRatioCorrection + 1) % 5;
_videoMode.aspectRatioCorrection = (_videoMode.aspectRatioCorrection + 1) % 7;
#else
if (_videoMode.aspectRatioCorrection == kAspectRatioNone)
_videoMode.aspectRatioCorrection = kAspectRatioConserve;
@ -1214,8 +1218,13 @@ Common::String OpenGLGraphicsManager::getAspectRatioName() {
return "16/9";
case kAspectRatio16_10:
return "16/10";
case kAspectRatio5_3:
return "5/3";
case kAspectRatio5_4:
return "5/4";
default:
return "";
}
return "";
}
uint OpenGLGraphicsManager::getAspectRatio() {
@ -1228,6 +1237,10 @@ uint OpenGLGraphicsManager::getAspectRatio() {
return 17777;
case kAspectRatio16_10:
return 16000;
case kAspectRatio5_3:
return 16666;
case kAspectRatio5_4:
return 12500;
default:
return _videoMode.hardwareWidth * 10000 / _videoMode.hardwareHeight;
}
@ -1297,7 +1310,7 @@ bool OpenGLGraphicsManager::saveScreenshot(const char *filename) {
int width = _videoMode.hardwareWidth;
int height = _videoMode.hardwareHeight;
// Allocate space for screenshot
// Allocate memory for screenshot
uint8 *pixels = new uint8[width * height * 3];
// Get pixel data from OpenGL buffer
@ -1336,6 +1349,7 @@ bool OpenGLGraphicsManager::saveScreenshot(const char *filename) {
// Write pixel data to BMP
out.write(pixels, width * height * 3);
// Free allocated memory
delete[] pixels;
return true;

View File

@ -33,7 +33,8 @@
// Uncomment this to enable the 'on screen display' code.
#define USE_OSD 1
// Uncomment this to enable all aspect ratio corrections (Will include 16/9 and 16/10)
// Uncomment this to enable all aspect ratio corrections
// (Will include 4/3, 16/9, 16/10, 5/3, 5/4)
//#define USE_ALL_ASR 1
namespace OpenGL {
@ -149,7 +150,9 @@ protected:
kAspectRatioConserve,
kAspectRatio4_3,
kAspectRatio16_9,
kAspectRatio16_10
kAspectRatio16_10,
kAspectRatio5_3,
kAspectRatio5_4
};
struct VideoState {

View File

@ -333,9 +333,9 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() {
// Do not downscale dimensions, only enlarge them if needed
if (screenAspectRatio > desiredAspectRatio)
_videoMode.hardwareHeight = _videoMode.overlayWidth * 10000 / desiredAspectRatio;
_videoMode.hardwareHeight = (_videoMode.overlayWidth * 10000 + 5000) / desiredAspectRatio;
else if (screenAspectRatio < desiredAspectRatio)
_videoMode.hardwareWidth = _videoMode.overlayHeight * desiredAspectRatio / 10000;
_videoMode.hardwareWidth = (_videoMode.overlayHeight * desiredAspectRatio + 5000) / 10000;
// Only adjust the overlay height if it is bigger than original one. If
// the width is modified it can break the overlay.