- Fixed: hud_scale is supposed use strictly integral scaling factors.

SVN r3776 (trunk)
This commit is contained in:
Randy Heit 2012-07-21 02:32:04 +00:00
commit 6760a3bfe9
5 changed files with 68 additions and 72 deletions

View file

@ -1324,10 +1324,7 @@ CCMD(clean)
bool V_DoModeSetup (int width, int height, int bits)
{
DFrameBuffer *buff = I_SetMode (width, height, screen);
int ratio;
int cwidth;
int cheight;
int cx1, cy1, cx2, cy2;
int cx1, cx2;
if (buff == NULL)
{
@ -1342,41 +1339,7 @@ bool V_DoModeSetup (int width, int height, int bits)
// if D3DFB is being used for the display.
FFont::StaticPreloadFonts();
ratio = CheckRatio (width, height);
if (ratio & 4)
{
cwidth = width;
cheight = height * BaseRatioSizes[ratio][3] / 48;
}
else
{
cwidth = width * BaseRatioSizes[ratio][3] / 48;
cheight = height;
}
// Use whichever pair of cwidth/cheight or width/height that produces less difference
// between CleanXfac and CleanYfac.
cx1 = MAX(cwidth / 320, 1);
cy1 = MAX(cheight / 200, 1);
cx2 = MAX(width / 320, 1);
cy2 = MAX(height / 200, 1);
if (abs(cx1 - cy1) <= abs(cx2 - cy2))
{ // e.g. 640x360 looks better with this.
CleanXfac = cx1;
CleanYfac = cy1;
}
else
{ // e.g. 720x480 looks better with this.
CleanXfac = cx2;
CleanYfac = cy2;
}
if (CleanXfac > 1 && CleanYfac > 1 && CleanXfac != CleanYfac)
{
if (CleanXfac < CleanYfac)
CleanYfac = CleanXfac;
else
CleanXfac = CleanYfac;
}
V_CalcCleanFacs(320, 200, width, height, &CleanXfac, &CleanYfac, &cx1, &cx2);
CleanWidth = width / CleanXfac;
CleanHeight = height / CleanYfac;
@ -1426,6 +1389,52 @@ bool V_DoModeSetup (int width, int height, int bits)
return true;
}
void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany, int *_cx1, int *_cx2)
{
int ratio;
int cwidth;
int cheight;
int cx1, cy1, cx2, cy2;
ratio = CheckRatio(realwidth, realheight);
if (ratio & 4)
{
cwidth = realwidth;
cheight = realheight * BaseRatioSizes[ratio][3] / 48;
}
else
{
cwidth = realwidth * BaseRatioSizes[ratio][3] / 48;
cheight = realheight;
}
// Use whichever pair of cwidth/cheight or width/height that produces less difference
// between CleanXfac and CleanYfac.
cx1 = MAX(cwidth / designwidth, 1);
cy1 = MAX(cheight / designheight, 1);
cx2 = MAX(realwidth / designwidth, 1);
cy2 = MAX(realheight / designheight, 1);
if (abs(cx1 - cy1) <= abs(cx2 - cy2))
{ // e.g. 640x360 looks better with this.
*cleanx = cx1;
*cleany = cy1;
}
else
{ // e.g. 720x480 looks better with this.
*cleanx = cx2;
*cleany = cy2;
}
if (*cleanx > 1 && *cleany > 1 && *cleanx != *cleany)
{
if (*cleanx < *cleany)
*cleany = *cleanx;
else
*cleanx = *cleany;
}
if (_cx1 != NULL) *_cx1 = cx1;
if (_cx2 != NULL) *_cx2 = cx2;
}
bool IVideo::SetResolution (int width, int height, int bits)
{
int oldwidth, oldheight;