mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-15 08:41:59 +00:00
Switch from ratio enum to float
This commit is contained in:
parent
6d4e4dad25
commit
5b438d220f
12 changed files with 55 additions and 82 deletions
|
@ -1108,13 +1108,13 @@ void DrawHUD()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (WidescreenRatio == 4)
|
||||
if (CheckRatio(SCREENWIDTH, SCREENHEIGHT) == 4)
|
||||
{
|
||||
hudheight = hudwidth * 30 / BaseRatioSizes[WidescreenRatio][3]; // BaseRatioSizes is inverted for this mode
|
||||
hudheight = hudwidth * 30 / AspectMultiplier(WidescreenRatio); // BaseRatioSizes is inverted for this mode
|
||||
}
|
||||
else
|
||||
{
|
||||
hudheight = hudwidth * 30 / (48*48/BaseRatioSizes[WidescreenRatio][3]);
|
||||
hudheight = hudwidth * 30 / (48*48/AspectMultiplier(WidescreenRatio));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -299,14 +299,15 @@ void DBaseStatusBar::SetScaled (bool scale, bool force)
|
|||
{
|
||||
ST_X = 0;
|
||||
ST_Y = VirticalResolution - RelTop;
|
||||
if (CheckRatio(SCREENWIDTH, SCREENHEIGHT) != 4)
|
||||
float aspect = ActiveRatio(SCREENWIDTH, SCREENHEIGHT);
|
||||
if (aspect >= 1.3f)
|
||||
{ // Normal resolution
|
||||
::ST_Y = Scale (ST_Y, SCREENHEIGHT, VirticalResolution);
|
||||
}
|
||||
else
|
||||
{ // 5:4 resolution
|
||||
::ST_Y = Scale(ST_Y - VirticalResolution/2, SCREENHEIGHT*3, Scale(VirticalResolution, BaseRatioSizes[4][1], 200)) + SCREENHEIGHT/2
|
||||
+ (SCREENHEIGHT - SCREENHEIGHT * BaseRatioSizes[4][3] / 48) / 2;
|
||||
::ST_Y = Scale(ST_Y - VirticalResolution/2, SCREENHEIGHT*3, Scale(VirticalResolution, AspectBaseHeight(aspect), 200)) + SCREENHEIGHT/2
|
||||
+ (SCREENHEIGHT - SCREENHEIGHT * AspectMultiplier(aspect) / 48) / 2;
|
||||
}
|
||||
Displacement = 0;
|
||||
}
|
||||
|
@ -1035,10 +1036,10 @@ void DBaseStatusBar::DrSmallNumberOuter (int val, int x, int y, bool center) con
|
|||
|
||||
void DBaseStatusBar::RefreshBackground () const
|
||||
{
|
||||
int x, x2, y, ratio;
|
||||
int x, x2, y;
|
||||
|
||||
ratio = CheckRatio (SCREENWIDTH, SCREENHEIGHT);
|
||||
x = (!IsRatioWidescreen(ratio) || !Scaled) ? ST_X : SCREENWIDTH*(48-BaseRatioSizes[ratio][3])/(48*2);
|
||||
float ratio = ActiveRatio (SCREENWIDTH, SCREENHEIGHT);
|
||||
x = (ratio < 1.5f || !Scaled) ? ST_X : SCREENWIDTH*(48-AspectMultiplier(ratio))/(48*2);
|
||||
y = x == ST_X && x > 0 ? ST_Y : ::ST_Y;
|
||||
|
||||
if(!CompleteBorder)
|
||||
|
@ -1058,8 +1059,8 @@ void DBaseStatusBar::RefreshBackground () const
|
|||
{
|
||||
if(!CompleteBorder)
|
||||
{
|
||||
x2 = !IsRatioWidescreen(ratio) || !Scaled ? ST_X+HorizontalResolution :
|
||||
SCREENWIDTH - (SCREENWIDTH*(48-BaseRatioSizes[ratio][3])+48*2-1)/(48*2);
|
||||
x2 = ratio < 1.5f || !Scaled ? ST_X+HorizontalResolution :
|
||||
SCREENWIDTH - (SCREENWIDTH*(48-AspectMultiplier(ratio))+48*2-1)/(48*2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -232,7 +232,7 @@ void R_SetVisibility(double vis)
|
|||
else
|
||||
r_WallVisibility = r_BaseVisibility;
|
||||
|
||||
r_WallVisibility = (InvZtoScale * SCREENWIDTH*BaseRatioSizes[WidescreenRatio][1] /
|
||||
r_WallVisibility = (InvZtoScale * SCREENWIDTH*AspectBaseHeight(WidescreenRatio) /
|
||||
(viewwidth*SCREENHEIGHT*3)) * (r_WallVisibility * FocalTangent);
|
||||
|
||||
// Prevent overflow on floors/ceilings. Note that the calculation of
|
||||
|
@ -295,7 +295,7 @@ CCMD (r_visibility)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, int trueratio)
|
||||
void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio)
|
||||
{
|
||||
int virtheight, virtwidth, virtwidth2, virtheight2;
|
||||
|
||||
|
@ -318,22 +318,22 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight,
|
|||
virtwidth = virtwidth2 = fullWidth;
|
||||
virtheight = virtheight2 = fullHeight;
|
||||
|
||||
if (Is54Aspect(trueratio))
|
||||
if (trueratio < 1.3f)
|
||||
{
|
||||
virtheight2 = virtheight2 * BaseRatioSizes[trueratio][3] / 48;
|
||||
virtheight2 = virtheight2 * AspectMultiplier(trueratio) / 48;
|
||||
}
|
||||
else
|
||||
{
|
||||
virtwidth2 = virtwidth2 * BaseRatioSizes[trueratio][3] / 48;
|
||||
virtwidth2 = virtwidth2 * AspectMultiplier(trueratio) / 48;
|
||||
}
|
||||
|
||||
if (Is54Aspect(WidescreenRatio))
|
||||
if (WidescreenRatio < 1.3f)
|
||||
{
|
||||
virtheight = virtheight * BaseRatioSizes[WidescreenRatio][3] / 48;
|
||||
virtheight = virtheight * AspectMultiplier(WidescreenRatio) / 48;
|
||||
}
|
||||
else
|
||||
{
|
||||
virtwidth = virtwidth * BaseRatioSizes[WidescreenRatio][3] / 48;
|
||||
virtwidth = virtwidth * AspectMultiplier(WidescreenRatio) / 48;
|
||||
}
|
||||
|
||||
BaseYaspectMul = 320.0 * virtheight2 / (r_Yaspect * virtwidth2);
|
||||
|
|
|
@ -55,7 +55,7 @@ struct FRenderer
|
|||
virtual void ErrorCleanup () {}
|
||||
virtual void ClearBuffer(int color) = 0;
|
||||
virtual void Init() = 0;
|
||||
virtual void SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, int trueratio) {}
|
||||
virtual void SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio) {}
|
||||
virtual void SetupFrame(player_t *player) {}
|
||||
virtual void CopyStackedViewParameters() {}
|
||||
virtual void RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov) = 0;
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
|
||||
class FArchive;
|
||||
void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, int trueratio);
|
||||
void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio);
|
||||
void R_SetupColormap(player_t *);
|
||||
void R_SetupFreelook();
|
||||
void R_InitRenderer();
|
||||
|
@ -275,7 +275,7 @@ void FSoftwareRenderer::ClearBuffer(int color)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
void FSoftwareRenderer::SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, int trueratio)
|
||||
void FSoftwareRenderer::SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio)
|
||||
{
|
||||
R_SWRSetWindow(windowSize, fullWidth, fullHeight, stHeight, trueratio);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ struct FSoftwareRenderer : public FRenderer
|
|||
void ErrorCleanup ();
|
||||
void ClearBuffer(int color);
|
||||
void Init();
|
||||
void SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, int trueratio);
|
||||
void SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio);
|
||||
void SetupFrame(player_t *player);
|
||||
void CopyStackedViewParameters();
|
||||
void RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov);
|
||||
|
|
|
@ -1393,7 +1393,7 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double
|
|||
}
|
||||
if (pspr->GetID() < PSP_TARGETCENTER)
|
||||
{ // Move the weapon down for 1280x1024.
|
||||
vis->texturemid -= BaseRatioSizes[WidescreenRatio][2];
|
||||
vis->texturemid -= AspectPspriteOffset(WidescreenRatio);
|
||||
}
|
||||
vis->x1 = x1 < 0 ? 0 : x1;
|
||||
vis->x2 = x2 >= viewwidth ? viewwidth : x2;
|
||||
|
|
|
@ -138,7 +138,7 @@ angle_t LocalViewAngle;
|
|||
int LocalViewPitch;
|
||||
bool LocalKeyboardTurner;
|
||||
|
||||
int WidescreenRatio;
|
||||
float WidescreenRatio;
|
||||
int setblocks;
|
||||
int extralight;
|
||||
bool setsizeneeded;
|
||||
|
@ -200,7 +200,7 @@ void R_SetViewSize (int blocks)
|
|||
|
||||
void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
|
||||
{
|
||||
int trueratio;
|
||||
float trueratio;
|
||||
|
||||
if (windowSize >= 11)
|
||||
{
|
||||
|
@ -220,8 +220,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
|
|||
freelookviewheight = ((setblocks*fullHeight)/10)&~7;
|
||||
}
|
||||
|
||||
// If the screen is approximately 16:9 or 16:10, consider it widescreen.
|
||||
WidescreenRatio = CheckRatio (fullWidth, fullHeight, &trueratio);
|
||||
WidescreenRatio = ActiveRatio (fullWidth, fullHeight, &trueratio);
|
||||
|
||||
DrawFSHUD = (windowSize == 11);
|
||||
|
||||
|
@ -230,13 +229,13 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
|
|||
|
||||
centery = viewheight/2;
|
||||
centerx = viewwidth/2;
|
||||
if (Is54Aspect(WidescreenRatio))
|
||||
if (WidescreenRatio < 1.3f)
|
||||
{
|
||||
centerxwide = centerx;
|
||||
}
|
||||
else
|
||||
{
|
||||
centerxwide = centerx * BaseRatioSizes[WidescreenRatio][3] / 48;
|
||||
centerxwide = centerx * AspectMultiplier(WidescreenRatio) / 48;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ extern int validcount;
|
|||
extern angle_t LocalViewAngle; // [RH] Added to consoleplayer's angle
|
||||
extern int LocalViewPitch; // [RH] Used directly instead of consoleplayer's pitch
|
||||
extern bool LocalKeyboardTurner; // [RH] The local player used the keyboard to turn, so interpolate
|
||||
extern int WidescreenRatio;
|
||||
extern float WidescreenRatio;
|
||||
|
||||
extern double r_TicFracF;
|
||||
extern DWORD r_FrameTime;
|
||||
|
|
|
@ -863,37 +863,37 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, double x, double y, DWORD tag
|
|||
void DCanvas::VirtualToRealCoords(double &x, double &y, double &w, double &h,
|
||||
double vwidth, double vheight, bool vbottom, bool handleaspect) const
|
||||
{
|
||||
int myratio = handleaspect ? CheckRatio (Width, Height) : 0;
|
||||
float myratio = handleaspect ? ActiveRatio (Width, Height) : (4.0f / 3.0f);
|
||||
|
||||
// if 21:9 AR, map to 16:9 for all callers.
|
||||
// this allows for black bars and stops the stretching of fullscreen images
|
||||
if (myratio == 6) {
|
||||
myratio = 2;
|
||||
if (myratio > 1.7f) {
|
||||
myratio = 16.0f / 9.0f;
|
||||
}
|
||||
|
||||
double right = x + w;
|
||||
double bottom = y + h;
|
||||
|
||||
if (myratio != 0 && myratio != 4)
|
||||
if (myratio > 1.4f)
|
||||
{ // The target surface is either 16:9 or 16:10, so expand the
|
||||
// specified virtual size to avoid undesired stretching of the
|
||||
// image. Does not handle non-4:3 virtual sizes. I'll worry about
|
||||
// those if somebody expresses a desire to use them.
|
||||
x = (x - vwidth * 0.5) * Width * 960 / (vwidth * BaseRatioSizes[myratio][0]) + Width * 0.5;
|
||||
w = (right - vwidth * 0.5) * Width * 960 / (vwidth * BaseRatioSizes[myratio][0]) + Width * 0.5 - x;
|
||||
x = (x - vwidth * 0.5) * Width * 960 / (vwidth * AspectBaseWidth(myratio)) + Width * 0.5;
|
||||
w = (right - vwidth * 0.5) * Width * 960 / (vwidth * AspectBaseWidth(myratio)) + Width * 0.5 - x;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = x * Width / vwidth;
|
||||
w = right * Width / vwidth - x;
|
||||
}
|
||||
if (myratio == 4)
|
||||
if (myratio < 1.3f)
|
||||
{ // The target surface is 5:4
|
||||
y = (y - vheight * 0.5) * Height * 600 / (vheight * BaseRatioSizes[myratio][1]) + Height * 0.5;
|
||||
h = (bottom - vheight * 0.5) * Height * 600 / (vheight * BaseRatioSizes[myratio][1]) + Height * 0.5 - y;
|
||||
y = (y - vheight * 0.5) * Height * 600 / (vheight * AspectBaseHeight(myratio)) + Height * 0.5;
|
||||
h = (bottom - vheight * 0.5) * Height * 600 / (vheight * AspectBaseHeight(myratio)) + Height * 0.5 - y;
|
||||
if (vbottom)
|
||||
{
|
||||
y += (Height - Height * BaseRatioSizes[myratio][3] / 48.0) * 0.5;
|
||||
y += (Height - Height * AspectMultiplier(myratio) / 48.0) * 0.5;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -937,30 +937,30 @@ void DCanvas::VirtualToRealCoordsInt(int &x, int &y, int &w, int &h,
|
|||
|
||||
void DCanvas::FillBorder (FTexture *img)
|
||||
{
|
||||
int myratio = CheckRatio (Width, Height);
|
||||
float myratio = ActiveRatio (Width, Height);
|
||||
|
||||
// if 21:9 AR, fill borders akin to 16:9, since all fullscreen
|
||||
// images are being drawn to that scale.
|
||||
if (myratio == 6) {
|
||||
myratio = 2;
|
||||
if (myratio > 1.7f) {
|
||||
myratio = 16 / 9.0f;
|
||||
}
|
||||
|
||||
if (myratio == 0)
|
||||
if (myratio >= 1.3f && myratio <= 1.4f)
|
||||
{ // This is a 4:3 display, so no border to show
|
||||
return;
|
||||
}
|
||||
int bordtop, bordbottom, bordleft, bordright, bord;
|
||||
if (Is54Aspect(myratio))
|
||||
if (myratio < 1.3f)
|
||||
{ // Screen is taller than it is wide
|
||||
bordleft = bordright = 0;
|
||||
bord = Height - Height * BaseRatioSizes[myratio][3] / 48;
|
||||
bord = Height - Height * AspectMultiplier(myratio) / 48;
|
||||
bordtop = bord / 2;
|
||||
bordbottom = bord - bordtop;
|
||||
}
|
||||
else
|
||||
{ // Screen is wider than it is tall
|
||||
bordtop = bordbottom = 0;
|
||||
bord = Width - Width * BaseRatioSizes[myratio][3] / 48;
|
||||
bord = Width - Width * AspectMultiplier(myratio) / 48;
|
||||
bordleft = bord / 2;
|
||||
bordright = bord - bordleft;
|
||||
}
|
||||
|
|
|
@ -1356,20 +1356,20 @@ void V_OutputResized (int width, int height)
|
|||
|
||||
void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany, int *_cx1, int *_cx2)
|
||||
{
|
||||
int ratio;
|
||||
float ratio;
|
||||
int cwidth;
|
||||
int cheight;
|
||||
int cx1, cy1, cx2, cy2;
|
||||
|
||||
ratio = CheckRatio(realwidth, realheight);
|
||||
if (Is54Aspect(ratio))
|
||||
ratio = ActiveRatio(realwidth, realheight);
|
||||
if (ratio < 1.3f)
|
||||
{
|
||||
cwidth = realwidth;
|
||||
cheight = realheight * BaseRatioSizes[ratio][3] / 48;
|
||||
cheight = realheight * AspectMultiplier(ratio) / 48;
|
||||
}
|
||||
else
|
||||
{
|
||||
cwidth = realwidth * BaseRatioSizes[ratio][3] / 48;
|
||||
cwidth = realwidth * AspectMultiplier(ratio) / 48;
|
||||
cheight = realheight;
|
||||
}
|
||||
// Use whichever pair of cwidth/cheight or width/height that produces less difference
|
||||
|
@ -1701,26 +1701,6 @@ int CheckRatio (int width, int height, int *trueratio)
|
|||
return fakeratio;
|
||||
}
|
||||
|
||||
// First column: Base width
|
||||
// Second column: Base height (used for wall visibility multiplier)
|
||||
// Third column: Psprite offset (needed for "tallscreen" modes)
|
||||
// Fourth column: Width or height multiplier
|
||||
|
||||
// For widescreen aspect ratio x:y ...
|
||||
// base_width = 240 * x / y
|
||||
// multiplier = 320 / base_width
|
||||
// base_height = 200 * multiplier
|
||||
const int BaseRatioSizes[7][4] =
|
||||
{
|
||||
{ 960, 600, 0, 48 }, // 4:3 320, 200, multiplied by three
|
||||
{ 1280, 450, 0, 48*3/4 }, // 16:9 426.6667, 150, multiplied by three
|
||||
{ 1152, 500, 0, 48*5/6 }, // 16:10 386, 166.6667, multiplied by three
|
||||
{ 1224, 471, 0, 48*40/51 }, // 17:10 408, 156.8627, multiplied by three
|
||||
{ 960, 640, (int)(6.5*FRACUNIT), 48*15/16 }, // 5:4 320, 213.3333, multiplied by three
|
||||
{ 1224, 471, 0, 48*40/51 }, // 17:10 408, 156.8627, multiplied by three (REDUNDANT)
|
||||
{ 1707, 338, 0, 48*9/16 } // 21:9 568.8889, 337.5, multiplied by three
|
||||
};
|
||||
|
||||
int AspectBaseWidth(float aspect)
|
||||
{
|
||||
return (int)round(240.0f * aspect * 3.0f);
|
||||
|
|
|
@ -516,6 +516,8 @@ extern "C" void ASM_PatchPitch (void);
|
|||
|
||||
int CheckRatio (int width, int height, int *trueratio=NULL);
|
||||
static inline int CheckRatio (double width, double height) { return CheckRatio(int(width), int(height)); }
|
||||
inline bool IsRatioWidescreen(int ratio) { return (ratio & 3) != 0; }
|
||||
|
||||
float ActiveRatio (int width, int height, float *trueratio = NULL);
|
||||
static inline double ActiveRatio (double width, double height) { return ActiveRatio(int(width), int(height)); }
|
||||
|
||||
|
@ -523,15 +525,6 @@ int AspectBaseWidth(float aspect);
|
|||
int AspectBaseHeight(float aspect);
|
||||
int AspectPspriteOffset(float aspect);
|
||||
int AspectMultiplier(float aspect);
|
||||
extern const int BaseRatioSizes[7][4];
|
||||
|
||||
inline bool IsRatioWidescreen(int ratio) {
|
||||
return (ratio & 3)!=0;
|
||||
}
|
||||
|
||||
inline bool Is54Aspect(int ratio) {
|
||||
return ratio == 4;
|
||||
}
|
||||
|
||||
EXTERN_CVAR(Int, uiscale);
|
||||
|
||||
|
|
Loading…
Reference in a new issue