summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Src/VideoConfig.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2010-04-04 22:52:27 +0000
committerJordan Woyak <jordan.woyak@gmail.com>2010-04-04 22:52:27 +0000
commit758bcf17cbde9e41e0ad68d74821a5a98587cf65 (patch)
treec2f0586d95867a656c521e8f0f8fb02546a61f7b /Source/Core/VideoCommon/Src/VideoConfig.cpp
parent675fc84255974ef1edb34eb77865ec9c94201fb6 (diff)
Tweaked the widescreen hack: It now "hacks" to and from any aspect ratio, not just from 4:3 to 16:9. When "Stretch to Window" is chosen, the aspect ratio will be adjusted to 5:4, 16:10, or anything (whatever the aspect ratio of the window is). Works for 4:3 and 16:9 games.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5280 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon/Src/VideoConfig.cpp')
-rw-r--r--Source/Core/VideoCommon/Src/VideoConfig.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp
index f8abe8d762..307fb3ec35 100644
--- a/Source/Core/VideoCommon/Src/VideoConfig.cpp
+++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp
@@ -35,6 +35,10 @@ VideoConfig::VideoConfig()
{
bRunning = false;
bAllowSignedBytes = !IsD3D();
+
+ // Needed for the first frame, I think
+ fAspectRatioHackW = 1;
+ fAspectRatioHackH = 1;
}
void VideoConfig::Load(const char *ini_file)
@@ -225,6 +229,52 @@ void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip
// Handle aspect ratio.
// Default to auto.
bool use16_9 = g_VideoInitialize.bAutoAspectIs16_9;
+
+ // Update aspect ratio hack values
+ // Won't take effect until next frame
+ // Don't know if there is a better place for this code so there isn't a 1 frame delay
+ if ( g_ActiveConfig.bWidescreenHack )
+ {
+ float source_aspect = use16_9 ? (16.0f / 9.0f) : (4.0f / 3.0f);
+ float target_aspect;
+
+ switch ( g_ActiveConfig.iAspectRatio )
+ {
+ case ASPECT_FORCE_16_9 :
+ target_aspect = 16.0f / 9.0f;
+ break;
+ case ASPECT_FORCE_4_3 :
+ target_aspect = 4.0f / 3.0f;
+ break;
+ case ASPECT_STRETCH :
+ target_aspect = WinWidth / WinHeight;
+ break;
+ default :
+ // ASPECT_AUTO == no hacking
+ target_aspect = source_aspect;
+ break;
+ }
+
+ float adjust = source_aspect / target_aspect;
+ if ( adjust > 1 )
+ {
+ // Vert+
+ g_Config.fAspectRatioHackW = 1;
+ g_Config.fAspectRatioHackH = 1/adjust;
+ }
+ else
+ {
+ // Hor+
+ g_Config.fAspectRatioHackW = adjust;
+ g_Config.fAspectRatioHackH = 1;
+ }
+ }
+ else
+ {
+ // Hack is disabled
+ g_Config.fAspectRatioHackW = 1;
+ g_Config.fAspectRatioHackH = 1;
+ }
// Check for force-settings and override.
if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_16_9)