diff options
author | Gavin Hayler | 2012-02-23 09:42:53 +0200 |
---|---|---|
committer | Gavin Hayler | 2012-02-23 16:27:04 +0200 |
commit | a71a91db17969cc4149905697dd84e72b1baf330 (patch) | |
tree | 0a1497fe3dd24550b6a9ebb4e22f5b775b8173b0 /backends/platform | |
parent | 5ae958bcf3a1dc4d7be093eac99eb0d5145c8c7e (diff) | |
download | scummvm-rg350-a71a91db17969cc4149905697dd84e72b1baf330.tar.gz scummvm-rg350-a71a91db17969cc4149905697dd84e72b1baf330.tar.bz2 scummvm-rg350-a71a91db17969cc4149905697dd84e72b1baf330.zip |
IPHONE: Add aspect ratio correction to iPhone
Diffstat (limited to 'backends/platform')
-rw-r--r-- | backends/platform/iphone/iphone_common.h | 2 | ||||
-rw-r--r-- | backends/platform/iphone/iphone_video.mm | 28 | ||||
-rw-r--r-- | backends/platform/iphone/osys_main.cpp | 5 |
3 files changed, 32 insertions, 3 deletions
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 18821e697f..d4c4cf3eb2 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -75,6 +75,8 @@ struct VideoContext { }; // On the ObjC side +void iPhone_setAspectRatioState(bool enable); +bool iPhone_getAspectRatioState(); void iPhone_updateScreen(); void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width); void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width); diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 387ed7252f..56c74b9ac5 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -53,6 +53,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) { @@ -73,6 +75,14 @@ void iPhone_setMouseCursor(unsigned short *buffer) { [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; } +void iPhone_setAspectRatioState(bool enable) { + _aspectRatioCorrect = enable; +} + +bool iPhone_getAspectRatioState() { + return _aspectRatioCorrect; +} + bool iPhone_isHighResDevice() { return _fullHeight > 480; } @@ -485,7 +495,7 @@ const char *iPhone_getDocumentsDir() { int screenWidth, screenHeight; [self setUpOrientation:[[UIDevice currentDevice] orientation] width:&screenWidth height:&screenHeight]; - + //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _videoContext.screenWidth, _videoContext.screenHeight, _gameScreenTextureWidth, _gameScreenTextureHeight); if (_screenTexture > 0) { @@ -516,10 +526,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! @@ -548,7 +570,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 368434c476..3c9d2d949c 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -119,6 +119,9 @@ void OSystem_IPHONE::setFeatureState(Feature f, bool enable) { _mouseCursorPaletteEnabled = enable; } break; + case kFeatureAspectRatioCorrection: + iPhone_setAspectRatioState(enable); + break; default: break; @@ -129,6 +132,8 @@ bool OSystem_IPHONE::getFeatureState(Feature f) { switch (f) { case kFeatureCursorPalette: return _mouseCursorPaletteEnabled; + case kFeatureAspectRatioCorrection: + return iPhone_getAspectRatioState(); default: return false; |