diff options
author | Johannes Schickel | 2012-02-24 22:32:49 +0100 |
---|---|---|
committer | Johannes Schickel | 2012-02-24 22:32:49 +0100 |
commit | 7fe3bdebc05252c02efdf5ba2680b54e2eca4263 (patch) | |
tree | 543532c9c3f129818912135b2e0256008ca62173 /backends | |
parent | 6b17507b76e3ac1efd8aa5dc12684a233d52046b (diff) | |
parent | a71a91db17969cc4149905697dd84e72b1baf330 (diff) | |
download | scummvm-rg350-7fe3bdebc05252c02efdf5ba2680b54e2eca4263.tar.gz scummvm-rg350-7fe3bdebc05252c02efdf5ba2680b54e2eca4263.tar.bz2 scummvm-rg350-7fe3bdebc05252c02efdf5ba2680b54e2eca4263.zip |
Merge pull request #197 from phoenixtail26/cleanedARCorrection.
This is a manual merge with some conflict fixups.
Conflicts:
backends/platform/iphone/iphone_video.mm
Diffstat (limited to 'backends')
-rw-r--r-- | backends/platform/iphone/iphone_common.h | 2 | ||||
-rw-r--r-- | backends/platform/iphone/iphone_video.mm | 26 | ||||
-rw-r--r-- | backends/platform/iphone/osys_main.cpp | 5 |
3 files changed, 31 insertions, 2 deletions
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 4dd9407064..3c0365eff5 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -86,6 +86,8 @@ struct VideoContext { }; // On the ObjC side +void iPhone_setAspectRatioState(bool enable); +bool iPhone_getAspectRatioState(); void iPhone_updateScreen(); bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY); const char *iPhone_getDocumentsDir(); diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 3aa76681ab..ecb514d633 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -41,6 +41,8 @@ static long lastTick = 0; static int frames = 0; #endif +static bool _aspectRatioCorrect = false; + #define printOpenGLError() printOglError(__FILE__, __LINE__) int printOglError(const char *file, int line) { @@ -56,6 +58,14 @@ int printOglError(const char *file, int line) { return retCode; } +void iPhone_setAspectRatioState(bool enable) { + _aspectRatioCorrect = enable; +} + +bool iPhone_getAspectRatioState() { + return _aspectRatioCorrect; +} + bool iPhone_isHighResDevice() { return _fullHeight > 480; } @@ -478,10 +488,22 @@ const char *iPhone_getDocumentsDir() { [[_keyboardView inputView] removeFromSuperview]; } + float adjustedWidth = _videoContext.screenWidth; + float adjustedHeight = _videoContext.screenHeight; + if (_aspectRatioCorrect && ((_videoContext.screenWidth == 320 && _videoContext.screenHeight == 200) + || (_videoContext.screenWidth == 640 && _videoContext.screenHeight == 400)) ) { + if (_videoContext.screenHeight == 200) { + adjustedHeight = 240; + } + if (_videoContext.screenHeight == 400) { + adjustedHeight = 480; + } + } + float overlayPortraitRatio; if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { - GLfloat gameScreenRatio = (GLfloat)_videoContext.screenWidth / (GLfloat)_videoContext.screenHeight; + GLfloat gameScreenRatio = (GLfloat)adjustedWidth / (GLfloat)adjustedHeight; GLfloat screenRatio = (GLfloat)screenWidth / (GLfloat)screenHeight; // These are the width/height according to the portrait layout! @@ -510,7 +532,7 @@ const char *iPhone_getDocumentsDir() { _gameScreenRect = CGRectMake(xOffset, yOffset, rectWidth, rectHeight); overlayPortraitRatio = 1.0f; } else { - float ratio = (float)_videoContext.screenHeight / (float)_videoContext.screenWidth; + float ratio = (float)adjustedHeight / (float)adjustedWidth; int height = (int)(screenWidth * ratio); //printf("Making rect (%u, %u)\n", screenWidth, height); _gameScreenRect = CGRectMake(0, 0, screenWidth, height); diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index dabf73bf58..71404dcd9e 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -118,6 +118,9 @@ void OSystem_IPHONE::setFeatureState(Feature f, bool enable) { _mouseCursorPaletteEnabled = enable; } break; + case kFeatureAspectRatioCorrection: + iPhone_setAspectRatioState(enable); + break; default: break; @@ -128,6 +131,8 @@ bool OSystem_IPHONE::getFeatureState(Feature f) { switch (f) { case kFeatureCursorPalette: return _mouseCursorPaletteEnabled; + case kFeatureAspectRatioCorrection: + return iPhone_getAspectRatioState(); default: return false; |