2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2009-09-13 08:21:35 +00:00
|
|
|
#include <cmath>
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "Common.h"
|
|
|
|
#include "IniFile.h"
|
2009-09-13 09:23:30 +00:00
|
|
|
#include "VideoConfig.h"
|
2009-09-13 08:21:35 +00:00
|
|
|
#include "VideoCommon.h"
|
2010-02-02 21:56:29 +00:00
|
|
|
#include "FileUtil.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-09-13 10:18:01 +00:00
|
|
|
VideoConfig g_Config;
|
|
|
|
VideoConfig g_ActiveConfig;
|
2009-09-13 08:21:35 +00:00
|
|
|
|
|
|
|
void UpdateActiveConfig()
|
|
|
|
{
|
|
|
|
g_ActiveConfig = g_Config;
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-09-13 10:18:01 +00:00
|
|
|
VideoConfig::VideoConfig()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-09-06 15:11:21 +00:00
|
|
|
bRunning = false;
|
2009-09-13 21:18:04 +00:00
|
|
|
bAllowSignedBytes = !IsD3D();
|
2010-04-04 22:52:27 +00:00
|
|
|
|
|
|
|
// Needed for the first frame, I think
|
|
|
|
fAspectRatioHackW = 1;
|
|
|
|
fAspectRatioHackH = 1;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-09-13 10:18:01 +00:00
|
|
|
void VideoConfig::Load(const char *ini_file)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
|
|
|
std::string temp;
|
|
|
|
IniFile iniFile;
|
2009-09-13 08:21:35 +00:00
|
|
|
iniFile.Load(ini_file);
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2010-06-03 04:55:39 +00:00
|
|
|
Section& hardware = iniFile["Hardware"];
|
|
|
|
hardware.Get("VSync", &bVSync, false); // Hardware
|
|
|
|
|
|
|
|
Section& settings = iniFile["Settings"];
|
|
|
|
settings.Get("StretchToFit", &bNativeResolution, true);
|
|
|
|
settings.Get("2xResolution", &b2xResolution, false);
|
|
|
|
settings.Get("wideScreenHack", &bWidescreenHack, false);
|
|
|
|
settings.Get("AspectRatio", &iAspectRatio, (int)ASPECT_AUTO);
|
|
|
|
settings.Get("Crop", &bCrop, false);
|
|
|
|
settings.Get("UseXFB", &bUseXFB, true);
|
|
|
|
settings.Get("UseRealXFB", &bUseRealXFB, false);
|
|
|
|
settings.Get("AutoScale", &bAutoScale, true);
|
|
|
|
settings.Get("UseNativeMips", &bUseNativeMips, true);
|
2008-12-20 22:18:52 +00:00
|
|
|
|
2010-06-03 04:55:39 +00:00
|
|
|
settings.Get("SafeTextureCache", &bSafeTextureCache, false); // Settings
|
First a bugfix:
fixed a misbehavior in the clear code that causes depth clear problems in reference hardware (Intel as example).
add 6 parameters to optimize Safe Texture Cache:
SafeTextureCacheColorSamples, SafeTextureCacheIndexedSamples, SafeTextureCacheTlutSamples:
this 3 parameters gives the number of samples taken to calculate the final hash value, less samples = more speed, more samples = more accuracy
if 0 is specified the hash is calculated using all the data in the texture.
SafeTextureCacheColorMaxSize, SafeTextureCacheIndexedMaxSize, SafeTextureCacheTlutMaxSize:
this parameters limits the amount of data used for the hash calculation, it could appear as redundant but in some games is better to make a full hash of the first bytes instead of some samples of all the texture.
color, indexed, tlut : define the texture type, full color data, indexed, and the tlut memory.
the parameters are available in the config , no GUI at this time, if the test are OK will add it to the GUI.
if someone needs it will give more examples on how to configure the values for specific games.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5116 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-02-23 21:52:12 +00:00
|
|
|
//Safe texture cache params
|
2010-06-03 04:55:39 +00:00
|
|
|
settings.Get("SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,512);
|
|
|
|
|
|
|
|
settings.Get("ShowFPS", &bShowFPS, false); // Settings
|
|
|
|
settings.Get("OverlayStats", &bOverlayStats, false);
|
|
|
|
settings.Get("OverlayProjStats", &bOverlayProjStats, false);
|
|
|
|
settings.Get("ShowEFBCopyRegions", &bShowEFBCopyRegions, false);
|
|
|
|
settings.Get("DLOptimize", &iCompileDLsLevel, 0);
|
|
|
|
settings.Get("DumpTextures", &bDumpTextures, false);
|
|
|
|
settings.Get("HiresTextures", &bHiresTextures, false);
|
|
|
|
settings.Get("DumpEFBTarget", &bDumpEFBTarget, false);
|
|
|
|
settings.Get("DumpFrames", &bDumpFrames, false);
|
|
|
|
settings.Get("FreeLook", &bFreeLook, false);
|
|
|
|
settings.Get("ShowShaderErrors", &bShowShaderErrors, false);
|
|
|
|
settings.Get("MSAA", &iMultisampleMode, 0);
|
|
|
|
settings.Get("DstAlphaPass", &bDstAlphaPass, false);
|
2008-12-20 22:18:52 +00:00
|
|
|
|
2010-06-03 04:55:39 +00:00
|
|
|
settings.Get("TexFmtOverlayEnable", &bTexFmtOverlayEnable, false);
|
|
|
|
settings.Get("TexFmtOverlayCenter", &bTexFmtOverlayCenter, false);
|
|
|
|
settings.Get("WireFrame", &bWireFrame, false);
|
|
|
|
settings.Get("DisableLighting", &bDisableLighting, false);
|
|
|
|
settings.Get("DisableTexturing", &bDisableTexturing, false);
|
|
|
|
settings.Get("DisableFog", &bDisableFog, false);
|
|
|
|
|
|
|
|
Section& enhancements = iniFile["Enhancements"];
|
|
|
|
enhancements.Get("ForceFiltering", &bForceFiltering, false);
|
|
|
|
enhancements.Get("MaxAnisotropy", &iMaxAnisotropy, 1); // NOTE - this is x in (1 << x)
|
|
|
|
enhancements.Get("PostProcessingShader", &sPostProcessingShader, "");
|
|
|
|
|
|
|
|
Section& hacks = iniFile["Hacks"];
|
|
|
|
hacks.Get("EFBAccessEnable", &bEFBAccessEnable, true);
|
|
|
|
hacks.Get("EFBCopyDisable", &bEFBCopyDisable, false);
|
|
|
|
hacks.Get("EFBCopyDisableHotKey", &bOSDHotKey, false);
|
|
|
|
hacks.Get("EFBToTextureEnable", &bCopyEFBToTexture, false);
|
|
|
|
hacks.Get("EFBScaledCopy", &bCopyEFBScaled, true);
|
|
|
|
hacks.Get("FIFOBPHack", &bFIFOBPhack, false);
|
|
|
|
hacks.Get("ProjectionHack", &iPhackvalue, 0);
|
|
|
|
|
|
|
|
hardware.Get("Adapter", &iAdapter, 0);
|
2009-09-13 08:21:35 +00:00
|
|
|
if (iAdapter == -1)
|
|
|
|
iAdapter = 0;
|
2010-06-03 04:55:39 +00:00
|
|
|
hardware.Get("SimpleFB", &bSimpleFB, false);
|
2009-09-13 08:21:35 +00:00
|
|
|
|
2009-06-04 21:21:07 +00:00
|
|
|
// Load common settings
|
2010-02-02 21:56:29 +00:00
|
|
|
iniFile.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
2009-06-04 21:21:07 +00:00
|
|
|
bool bTmp;
|
2010-06-03 04:55:39 +00:00
|
|
|
iniFile["Interface"].Get("UsePanicHandlers", &bTmp, true);
|
2009-06-04 21:21:07 +00:00
|
|
|
SetEnableAlert(bTmp);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-09-13 10:18:01 +00:00
|
|
|
void VideoConfig::GameIniLoad(const char *ini_file)
|
2009-06-28 16:47:14 +00:00
|
|
|
{
|
2009-09-13 08:54:46 +00:00
|
|
|
IniFile iniFile;
|
|
|
|
iniFile.Load(ini_file);
|
2009-09-15 08:13:45 +00:00
|
|
|
|
2010-06-03 04:55:39 +00:00
|
|
|
Section& video = iniFile["Video"];
|
|
|
|
|
|
|
|
video.Get("ForceFiltering", &bForceFiltering, bForceFiltering);
|
|
|
|
video.Get("MaxAnisotropy", &iMaxAnisotropy, iMaxAnisotropy); // NOTE - this is x in (1 << x)
|
|
|
|
video.Get("EFBCopyDisable", &bEFBCopyDisable, bEFBCopyDisable);
|
|
|
|
video.Get("EFBCopyDisableHotKey", &bOSDHotKey, bOSDHotKey);
|
|
|
|
video.Get("EFBToTextureEnable", &bCopyEFBToTexture, bCopyEFBToTexture);
|
|
|
|
video.Get("EFBScaledCopy", &bCopyEFBScaled, bCopyEFBScaled);
|
|
|
|
video.Get("SafeTextureCache", &bSafeTextureCache, bSafeTextureCache);
|
First a bugfix:
fixed a misbehavior in the clear code that causes depth clear problems in reference hardware (Intel as example).
add 6 parameters to optimize Safe Texture Cache:
SafeTextureCacheColorSamples, SafeTextureCacheIndexedSamples, SafeTextureCacheTlutSamples:
this 3 parameters gives the number of samples taken to calculate the final hash value, less samples = more speed, more samples = more accuracy
if 0 is specified the hash is calculated using all the data in the texture.
SafeTextureCacheColorMaxSize, SafeTextureCacheIndexedMaxSize, SafeTextureCacheTlutMaxSize:
this parameters limits the amount of data used for the hash calculation, it could appear as redundant but in some games is better to make a full hash of the first bytes instead of some samples of all the texture.
color, indexed, tlut : define the texture type, full color data, indexed, and the tlut memory.
the parameters are available in the config , no GUI at this time, if the test are OK will add it to the GUI.
if someone needs it will give more examples on how to configure the values for specific games.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5116 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-02-23 21:52:12 +00:00
|
|
|
//Safe texture cache params
|
2010-06-03 04:55:39 +00:00
|
|
|
video.Get("SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples, iSafeTextureCache_ColorSamples);
|
|
|
|
|
|
|
|
video.Get("MSAA", &iMultisampleMode, iMultisampleMode);
|
|
|
|
video.Get("DstAlphaPass", &bDstAlphaPass, bDstAlphaPass);
|
|
|
|
video.Get("UseXFB", &bUseXFB, bUseXFB);
|
|
|
|
video.Get("UseRealXFB", &bUseRealXFB, bUseRealXFB);
|
|
|
|
video.Get("FIFOBPHack", &bFIFOBPhack, bFIFOBPhack);
|
|
|
|
video.Get("ProjectionHack", &iPhackvalue, iPhackvalue);
|
|
|
|
video.Get("UseNativeMips", &bUseNativeMips, bUseNativeMips);
|
2009-03-20 11:51:22 +00:00
|
|
|
}
|
|
|
|
|
2009-09-13 10:18:01 +00:00
|
|
|
void VideoConfig::Save(const char *ini_file)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
|
|
|
IniFile iniFile;
|
2009-09-13 08:21:35 +00:00
|
|
|
iniFile.Load(ini_file);
|
2010-06-03 04:55:39 +00:00
|
|
|
|
|
|
|
Section& hardware = iniFile["Hardware"];
|
|
|
|
hardware.Set("VSync", bVSync);
|
|
|
|
|
|
|
|
Section& settings = iniFile["Settings"];
|
|
|
|
settings.Set("StretchToFit", bNativeResolution);
|
|
|
|
settings.Set("2xResolution", b2xResolution);
|
|
|
|
settings.Set("AspectRatio", iAspectRatio);
|
|
|
|
settings.Set("Crop", bCrop);
|
|
|
|
settings.Set("wideScreenHack", bWidescreenHack);
|
|
|
|
settings.Set("UseXFB", bUseXFB);
|
|
|
|
settings.Set("UseRealXFB", bUseRealXFB);
|
|
|
|
settings.Set("AutoScale", bAutoScale);
|
|
|
|
settings.Set("UseNativeMips", bUseNativeMips);
|
|
|
|
|
|
|
|
settings.Set("SafeTextureCache", bSafeTextureCache);
|
First a bugfix:
fixed a misbehavior in the clear code that causes depth clear problems in reference hardware (Intel as example).
add 6 parameters to optimize Safe Texture Cache:
SafeTextureCacheColorSamples, SafeTextureCacheIndexedSamples, SafeTextureCacheTlutSamples:
this 3 parameters gives the number of samples taken to calculate the final hash value, less samples = more speed, more samples = more accuracy
if 0 is specified the hash is calculated using all the data in the texture.
SafeTextureCacheColorMaxSize, SafeTextureCacheIndexedMaxSize, SafeTextureCacheTlutMaxSize:
this parameters limits the amount of data used for the hash calculation, it could appear as redundant but in some games is better to make a full hash of the first bytes instead of some samples of all the texture.
color, indexed, tlut : define the texture type, full color data, indexed, and the tlut memory.
the parameters are available in the config , no GUI at this time, if the test are OK will add it to the GUI.
if someone needs it will give more examples on how to configure the values for specific games.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5116 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-02-23 21:52:12 +00:00
|
|
|
//safe texture cache params
|
2010-06-03 04:55:39 +00:00
|
|
|
settings.Set("SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples);
|
|
|
|
|
|
|
|
settings.Set("ShowFPS", bShowFPS);
|
|
|
|
settings.Set("OverlayStats", bOverlayStats);
|
|
|
|
settings.Set("OverlayProjStats", bOverlayProjStats);
|
|
|
|
settings.Set("DLOptimize", iCompileDLsLevel);
|
|
|
|
settings.Set("Show", iCompileDLsLevel);
|
|
|
|
settings.Set("DumpTextures", bDumpTextures);
|
|
|
|
settings.Set("HiresTextures", bHiresTextures);
|
|
|
|
settings.Set("DumpEFBTarget", bDumpEFBTarget);
|
|
|
|
settings.Set("DumpFrames", bDumpFrames);
|
|
|
|
settings.Set("FreeLook", bFreeLook);
|
|
|
|
settings.Set("ShowEFBCopyRegions", bShowEFBCopyRegions);
|
|
|
|
settings.Set("ShowShaderErrors", bShowShaderErrors);
|
|
|
|
settings.Set("MSAA", iMultisampleMode);
|
|
|
|
settings.Set("TexFmtOverlayEnable", bTexFmtOverlayEnable);
|
|
|
|
settings.Set("TexFmtOverlayCenter", bTexFmtOverlayCenter);
|
|
|
|
settings.Set("Wireframe", bWireFrame);
|
|
|
|
settings.Set("DisableLighting", bDisableLighting);
|
|
|
|
settings.Set("DisableTexturing", bDisableTexturing);
|
|
|
|
settings.Set("DstAlphaPass", bDstAlphaPass);
|
|
|
|
settings.Set("DisableFog", bDisableFog);
|
2008-12-20 22:18:52 +00:00
|
|
|
|
2010-06-03 04:55:39 +00:00
|
|
|
Section& enhancements = iniFile["Enhancements"];
|
|
|
|
enhancements.Set("ForceFiltering", bForceFiltering);
|
|
|
|
enhancements.Set("MaxAnisotropy", iMaxAnisotropy);
|
|
|
|
enhancements.Set("PostProcessingShader", sPostProcessingShader);
|
2008-12-20 22:18:52 +00:00
|
|
|
|
2010-06-03 04:55:39 +00:00
|
|
|
Section& hacks = iniFile["Hacks"];
|
|
|
|
hacks.Set("EFBAccessEnable", bEFBAccessEnable);
|
|
|
|
hacks.Set("EFBCopyDisable", bEFBCopyDisable);
|
|
|
|
hacks.Set("EFBCopyDisableHotKey", bOSDHotKey);
|
|
|
|
hacks.Set("EFBToTextureEnable", bCopyEFBToTexture);
|
|
|
|
hacks.Set("EFBScaledCopy", bCopyEFBScaled);
|
|
|
|
hacks.Set("FIFOBPHack", bFIFOBPhack);
|
|
|
|
hacks.Set("ProjectionHack", iPhackvalue);
|
|
|
|
|
|
|
|
hardware.Set("Adapter", iAdapter);
|
|
|
|
hardware.Set("SimpleFB", bSimpleFB);
|
2009-09-13 08:21:35 +00:00
|
|
|
|
|
|
|
iniFile.Save(ini_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Figure out a better place for this function.
|
|
|
|
void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip, TargetRectangle *rc)
|
|
|
|
{
|
|
|
|
float FloatGLWidth = (float)backbuffer_width;
|
|
|
|
float FloatGLHeight = (float)backbuffer_height;
|
|
|
|
float FloatXOffset = 0;
|
|
|
|
float FloatYOffset = 0;
|
|
|
|
|
|
|
|
// The rendering window size
|
|
|
|
const float WinWidth = FloatGLWidth;
|
|
|
|
const float WinHeight = FloatGLHeight;
|
|
|
|
|
|
|
|
// Handle aspect ratio.
|
2010-01-13 21:11:02 +00:00
|
|
|
// Default to auto.
|
|
|
|
bool use16_9 = g_VideoInitialize.bAutoAspectIs16_9;
|
2010-04-04 22:52:27 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
2010-01-13 21:11:02 +00:00
|
|
|
|
|
|
|
// Check for force-settings and override.
|
|
|
|
if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_16_9)
|
|
|
|
use16_9 = true;
|
|
|
|
else if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_4_3)
|
|
|
|
use16_9 = false;
|
|
|
|
|
|
|
|
if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH)
|
2009-09-13 08:21:35 +00:00
|
|
|
{
|
|
|
|
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
|
2010-01-13 21:11:02 +00:00
|
|
|
float Ratio = (WinWidth / WinHeight) / (!use16_9 ? (4.0f / 3.0f) : (16.0f / 9.0f));
|
2009-09-13 17:46:33 +00:00
|
|
|
// Check if height or width is the limiting factor. If ratio > 1 the picture is too wide and have to limit the width.
|
|
|
|
if (Ratio > 1.0f)
|
2009-09-13 08:21:35 +00:00
|
|
|
{
|
|
|
|
// Scale down and center in the X direction.
|
|
|
|
FloatGLWidth /= Ratio;
|
|
|
|
FloatXOffset = (WinWidth - FloatGLWidth) / 2.0f;
|
|
|
|
}
|
|
|
|
// The window is too high, we have to limit the height
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Scale down and center in the Y direction.
|
|
|
|
FloatGLHeight *= Ratio;
|
|
|
|
FloatYOffset = FloatYOffset + (WinHeight - FloatGLHeight) / 2.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10.
|
|
|
|
// Output: FloatGLWidth, FloatGLHeight, FloatXOffset, FloatYOffset
|
|
|
|
// ------------------
|
2010-01-13 21:11:02 +00:00
|
|
|
if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH && g_ActiveConfig.bCrop)
|
2009-09-13 08:21:35 +00:00
|
|
|
{
|
2010-01-13 21:11:02 +00:00
|
|
|
float Ratio = !use16_9 ? ((4.0f / 3.0f) / (5.0f / 4.0f)) : (((16.0f / 9.0f) / (16.0f / 10.0f)));
|
2009-09-13 08:21:35 +00:00
|
|
|
// The width and height we will add (calculate this before FloatGLWidth and FloatGLHeight is adjusted)
|
|
|
|
float IncreasedWidth = (Ratio - 1.0f) * FloatGLWidth;
|
|
|
|
float IncreasedHeight = (Ratio - 1.0f) * FloatGLHeight;
|
|
|
|
// The new width and height
|
|
|
|
FloatGLWidth = FloatGLWidth * Ratio;
|
|
|
|
FloatGLHeight = FloatGLHeight * Ratio;
|
|
|
|
// Adjust the X and Y offset
|
|
|
|
FloatXOffset = FloatXOffset - (IncreasedWidth * 0.5f);
|
|
|
|
FloatYOffset = FloatYOffset - (IncreasedHeight * 0.5f);
|
|
|
|
}
|
|
|
|
|
|
|
|
int XOffset = (int)(FloatXOffset + 0.5f);
|
|
|
|
int YOffset = (int)(FloatYOffset + 0.5f);
|
2010-02-03 03:52:50 +00:00
|
|
|
int iWhidth = (int)ceil(FloatGLWidth);
|
|
|
|
int iHeight = (int)ceil(FloatGLHeight);
|
2010-02-03 14:13:03 +00:00
|
|
|
iWhidth -= iWhidth % 4; // ensure divisibility by 4 to make it compatible with all the video encoders
|
2010-02-03 03:52:50 +00:00
|
|
|
iHeight -= iHeight % 4;
|
2009-09-13 08:21:35 +00:00
|
|
|
rc->left = XOffset;
|
2010-02-03 03:52:50 +00:00
|
|
|
rc->top = flip ? (int)(YOffset + iHeight) : YOffset;
|
|
|
|
rc->right = XOffset + iWhidth;
|
|
|
|
rc->bottom = flip ? YOffset : (int)(YOffset + iHeight);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|