summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authordonkopunchstania <donkopunchstania@gmail.com>2011-01-07 04:57:59 +0000
committerdonkopunchstania <donkopunchstania@gmail.com>2011-01-07 04:57:59 +0000
commitd16357cd5ce810c74fcee602ed13028d397c6254 (patch)
tree686b83ec22a0fc123666105afdb7a919f085274b /Source/Core/VideoCommon
parent49b7da6445013c33a89fa6d68b2b64bcd538c7eb (diff)
Add anvideo config option to automatically resize the render window to the size of the game's output resolution. This avoids artifacts that appear when the render target is scaled to fit a window of a different size.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6764 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Src/EmuWindow.cpp2
-rw-r--r--Source/Core/VideoCommon/Src/RenderBase.cpp53
-rw-r--r--Source/Core/VideoCommon/Src/RenderBase.h1
-rw-r--r--Source/Core/VideoCommon/Src/VideoConfig.cpp2
-rw-r--r--Source/Core/VideoCommon/Src/VideoConfig.h1
5 files changed, 38 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/Src/EmuWindow.cpp b/Source/Core/VideoCommon/Src/EmuWindow.cpp
index 62882c48e6..3f37687f26 100644
--- a/Source/Core/VideoCommon/Src/EmuWindow.cpp
+++ b/Source/Core/VideoCommon/Src/EmuWindow.cpp
@@ -323,7 +323,7 @@ HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)
// 3. Request window sizes which actually make the client area map to a common resolution
HWND Ret;
int x=0, y=0, width=640, height=480;
- g_VideoInitialize.pRequestWindowSize(x, y, width, height);
+ g_VideoInitialize.pGetWindowSize(x, y, width, height);
// TODO: Don't show if fullscreen
Ret = OpenWindow(hParent, hInstance, width, height, title);
diff --git a/Source/Core/VideoCommon/Src/RenderBase.cpp b/Source/Core/VideoCommon/Src/RenderBase.cpp
index 4e67c5c72f..4d584f2711 100644
--- a/Source/Core/VideoCommon/Src/RenderBase.cpp
+++ b/Source/Core/VideoCommon/Src/RenderBase.cpp
@@ -114,13 +114,42 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
}
}
+void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY)
+{
+ switch (g_ActiveConfig.iEFBScale)
+ {
+ case 3: // 2x
+ scaledX = x * 2;
+ scaledY = y * 2;
+ break;
+ case 4: // 3x
+ scaledX = x * 3;
+ scaledY = y * 3;
+ break;
+ case 5: // 0.75x
+ scaledX = (x * 3) / 4;
+ scaledY = (y * 3) / 4;
+ break;
+ case 6: // 0.5x
+ scaledX = x / 2;
+ scaledY = y / 2;
+ break;
+ case 7: // 0.375x
+ scaledX = (x * 3) / 8;
+ scaledY = (y * 3) / 8;
+ break;
+ default:
+ scaledX = x;
+ scaledY = y;
+ };
+}
+
// return true if target size changed
bool Renderer::CalculateTargetSize(int multiplier)
{
int newEFBWidth, newEFBHeight;
switch (s_LastEFBScale)
{
- default:
case 0: // fractional
newEFBWidth = (int)(EFB_WIDTH * xScale);
newEFBHeight = (int)(EFB_HEIGHT * yScale);
@@ -129,25 +158,9 @@ bool Renderer::CalculateTargetSize(int multiplier)
newEFBWidth = EFB_WIDTH * (int)ceilf(xScale);
newEFBHeight = EFB_HEIGHT * (int)ceilf(yScale);
break;
- case 2: // 1x
- case 3: // 2x
- case 4: // 3x
- newEFBWidth = EFB_WIDTH * (g_ActiveConfig.iEFBScale - 1);
- newEFBHeight = EFB_HEIGHT * (g_ActiveConfig.iEFBScale - 1);
- break;
- case 5: // 0.75x
- newEFBWidth = (EFB_WIDTH * 3) / 4;
- newEFBHeight = (EFB_HEIGHT * 3) / 4;
- break;
- case 6: // 0.5x
- newEFBWidth = EFB_WIDTH / 2;
- newEFBHeight = EFB_HEIGHT / 2;
- break;
- case 7: // 0.375x
- newEFBWidth = (EFB_WIDTH * 3) / 8;
- newEFBHeight = (EFB_HEIGHT * 3) / 8;
- break;
- };
+ default:
+ CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT, newEFBWidth, newEFBHeight);
+ }
newEFBWidth *= multiplier;
newEFBHeight *= multiplier;
diff --git a/Source/Core/VideoCommon/Src/RenderBase.h b/Source/Core/VideoCommon/Src/RenderBase.h
index 58e4699d5d..1d265083d9 100644
--- a/Source/Core/VideoCommon/Src/RenderBase.h
+++ b/Source/Core/VideoCommon/Src/RenderBase.h
@@ -134,6 +134,7 @@ protected:
static Common::CriticalSection s_criticalScreenshot;
static std::string s_sScreenshotName;
+ static void CalculateTargetScale(int x, int y, int &scaledX, int &scaledY);
static bool CalculateTargetSize(int multiplier = 1);
static void CalculateXYScale(const TargetRectangle& dst_rect);
diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp
index ddca461be9..f08cbe8a7f 100644
--- a/Source/Core/VideoCommon/Src/VideoConfig.cpp
+++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp
@@ -61,6 +61,7 @@ void VideoConfig::Load(const char *ini_file)
iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
iniFile.Get("Settings", "UseRealXFB", &bUseRealXFB, 0);
iniFile.Get("Settings", "UseNativeMips", &bUseNativeMips, true);
+ iniFile.Get("Settings", "AdjustWindowSize", &bAdjustWindowSize, false);
iniFile.Get("Settings", "SafeTextureCache", &bSafeTextureCache, false); // Settings
//Safe texture cache params
@@ -179,6 +180,7 @@ void VideoConfig::Save(const char *ini_file)
iniFile.Set("Settings", "UseXFB", bUseXFB);
iniFile.Set("Settings", "UseRealXFB", bUseRealXFB);
iniFile.Set("Settings", "UseNativeMips", bUseNativeMips);
+ iniFile.Set("Settings", "AdjustWindowSize", bAdjustWindowSize);
iniFile.Set("Settings", "SafeTextureCache", bSafeTextureCache);
//safe texture cache params
diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h
index 9ffffe2f0c..276ef6f903 100644
--- a/Source/Core/VideoCommon/Src/VideoConfig.h
+++ b/Source/Core/VideoCommon/Src/VideoConfig.h
@@ -77,6 +77,7 @@ struct VideoConfig
bool bUseXFB;
bool bUseRealXFB;
bool bUseNativeMips;
+ bool bAdjustWindowSize;
// OpenCL
bool bEnableOpenCL;