mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-24 13:01:48 +00:00
- Fixed voxel rendering to not get the vertical scale horribly messed up when forcing an aspect
ratio with vid_aspect/vid_nowidescreen that does not match the dimensions of the resolution. SVN r3079 (voxel)
This commit is contained in:
parent
a18744224c
commit
1b69ee54cc
4 changed files with 49 additions and 17 deletions
|
@ -160,6 +160,7 @@ fixed_t globaluclip, globaldclip;
|
|||
fixed_t centerxfrac;
|
||||
fixed_t centeryfrac;
|
||||
fixed_t yaspectmul;
|
||||
fixed_t baseyaspectmul; // yaspectmul without a forced aspect ratio
|
||||
float iyaspectmulfloat;
|
||||
fixed_t InvZtoScale;
|
||||
|
||||
|
@ -604,7 +605,7 @@ void R_SetViewSize (int blocks)
|
|||
|
||||
void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
|
||||
{
|
||||
int virtheight, virtwidth;
|
||||
int virtheight, virtwidth, trueratio, virtwidth2, virtheight2;
|
||||
|
||||
if (windowSize >= 11)
|
||||
{
|
||||
|
@ -625,7 +626,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
|
|||
}
|
||||
|
||||
// If the screen is approximately 16:9 or 16:10, consider it widescreen.
|
||||
WidescreenRatio = CheckRatio (fullWidth, fullHeight);
|
||||
WidescreenRatio = CheckRatio (fullWidth, fullHeight, &trueratio);
|
||||
|
||||
DrawFSHUD = (windowSize == 11);
|
||||
|
||||
|
@ -648,8 +649,18 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
|
|||
centerxfrac = centerx<<FRACBITS;
|
||||
centeryfrac = centery<<FRACBITS;
|
||||
|
||||
virtwidth = fullWidth;
|
||||
virtheight = fullHeight;
|
||||
virtwidth = virtwidth2 = fullWidth;
|
||||
virtheight = virtheight2 = fullHeight;
|
||||
|
||||
if (trueratio & 4)
|
||||
{
|
||||
virtheight2 = virtheight2 * BaseRatioSizes[trueratio][3] / 48;
|
||||
}
|
||||
else
|
||||
{
|
||||
virtwidth2 = virtwidth2 * BaseRatioSizes[trueratio][3] / 48;
|
||||
}
|
||||
|
||||
if (WidescreenRatio & 4)
|
||||
{
|
||||
virtheight = virtheight * BaseRatioSizes[WidescreenRatio][3] / 48;
|
||||
|
@ -661,6 +672,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
|
|||
centerxwide = centerx * BaseRatioSizes[WidescreenRatio][3] / 48;
|
||||
}
|
||||
|
||||
baseyaspectmul = Scale(320 << FRACBITS, virtheight2, r_Yaspect * virtwidth2);
|
||||
yaspectmul = Scale ((320<<FRACBITS), virtheight, r_Yaspect * virtwidth);
|
||||
iyaspectmulfloat = (float)virtwidth * r_Yaspect / 320.f / (float)virtheight;
|
||||
InvZtoScale = yaspectmul * centerx;
|
||||
|
|
|
@ -3244,6 +3244,8 @@ static fixed_t distrecip(fixed_t y)
|
|||
return y == 0 ? 0 : SafeDivScale32(centerxwide, y);
|
||||
}
|
||||
|
||||
extern fixed_t baseyaspectmul;
|
||||
|
||||
void R_DrawVoxel(fixed_t dasprx, fixed_t daspry, fixed_t dasprz, angle_t dasprang,
|
||||
fixed_t daxscale, fixed_t dayscale, FVoxel *voxobj,
|
||||
lighttable_t *colormap, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags)
|
||||
|
@ -3293,7 +3295,7 @@ void R_DrawVoxel(fixed_t dasprx, fixed_t daspry, fixed_t dasprz, angle_t daspran
|
|||
maxslabz >>= k;
|
||||
|
||||
daxscale <<= (k+8); dayscale <<= (k+8);
|
||||
dazscale = FixedDiv(dayscale, yaspectmul);
|
||||
dazscale = FixedDiv(dayscale, baseyaspectmul);
|
||||
daxscale = FixedDiv(daxscale, yaspectmul);
|
||||
daxscale = Scale(daxscale, xdimenscale, centerxwide << 9);
|
||||
dayscale = Scale(dayscale, FixedMul(xdimenscale, viewingrangerecip), centerxwide << 9);
|
||||
|
|
|
@ -1739,43 +1739,61 @@ CUSTOM_CVAR (Int, vid_aspect, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
|||
// 1: 16:9
|
||||
// 2: 16:10
|
||||
// 4: 5:4
|
||||
int CheckRatio (int width, int height)
|
||||
int CheckRatio (int width, int height, int *trueratio)
|
||||
{
|
||||
int fakeratio = -1;
|
||||
int ratio;
|
||||
|
||||
if ((vid_aspect >=1) && (vid_aspect <=4))
|
||||
{
|
||||
// [SP] User wants to force aspect ratio; let them.
|
||||
return vid_aspect == 3? 0: int(vid_aspect);
|
||||
fakeratio = vid_aspect == 3? 0: int(vid_aspect);
|
||||
}
|
||||
if (vid_nowidescreen)
|
||||
{
|
||||
if (!vid_tft)
|
||||
{
|
||||
return 0;
|
||||
fakeratio = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fakeratio = (height * 5/4 == width) ? 4 : 0;
|
||||
}
|
||||
return (height * 5/4 == width) ? 4 : 0;
|
||||
}
|
||||
// If the size is approximately 16:9, consider it so.
|
||||
if (abs (height * 16/9 - width) < 10)
|
||||
{
|
||||
return 1;
|
||||
ratio = 1;
|
||||
}
|
||||
// 16:10 has more variance in the pixel dimensions. Grr.
|
||||
if (abs (height * 16/10 - width) < 60)
|
||||
else if (abs (height * 16/10 - width) < 60)
|
||||
{
|
||||
// 320x200 and 640x400 are always 4:3, not 16:10
|
||||
if ((width == 320 && height == 200) || (width == 640 && height == 400))
|
||||
{
|
||||
return 0;
|
||||
ratio = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ratio = 2;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
// Unless vid_tft is set, 1280x1024 is 4:3, not 5:4.
|
||||
if (height * 5/4 == width && vid_tft)
|
||||
else if (height * 5/4 == width && vid_tft)
|
||||
{
|
||||
return 4;
|
||||
ratio = 4;
|
||||
}
|
||||
// Assume anything else is 4:3.
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
ratio = 0;
|
||||
}
|
||||
|
||||
if (trueratio != NULL)
|
||||
{
|
||||
*trueratio = ratio;
|
||||
}
|
||||
return (fakeratio >= 0) ? fakeratio : ratio;
|
||||
}
|
||||
|
||||
// First column: Base width (unused)
|
||||
|
|
|
@ -500,7 +500,7 @@ void V_DrawFrame (int left, int top, int width, int height);
|
|||
extern "C" void ASM_PatchPitch (void);
|
||||
#endif
|
||||
|
||||
int CheckRatio (int width, int height);
|
||||
int CheckRatio (int width, int height, int *trueratio=NULL);
|
||||
static inline int CheckRatio (double width, double height) { return CheckRatio(int(width), int(height)); }
|
||||
extern const int BaseRatioSizes[5][4];
|
||||
|
||||
|
|
Loading…
Reference in a new issue