mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- export common formulae to functions instead of copy-pasting them
- screen bevel now enlarges also when screenblocks <= 11 - make intermission and status bar scaling game-specific in the config - add scaling customization for classic ui flat scaling - make screen border flat scale up - inter_classic_scaling now defaults to true - fixed: last commit I accidentally left hardcoded testing values and did not change them back to check for the texture's original size - implement cvar 'inter_classic_scaling' to render the intermission flat as if it were 320x200
This commit is contained in:
parent
0f0768652a
commit
6e3ec96250
5 changed files with 107 additions and 24 deletions
|
@ -37,12 +37,15 @@
|
|||
#include "vm.h"
|
||||
#include "c_cvars.h"
|
||||
#include "v_draw.h"
|
||||
#include "v_video.h"
|
||||
#include "fcolormap.h"
|
||||
|
||||
static F2DDrawer drawer;
|
||||
F2DDrawer* twod = &drawer;
|
||||
|
||||
EXTERN_CVAR(Float, transsouls)
|
||||
CVAR(Float, classic_scaling_factor, 1.0, CVAR_ARCHIVE)
|
||||
CVAR(Float, classic_scaling_pixelaspect, 1.2, CVAR_ARCHIVE)
|
||||
|
||||
IMPLEMENT_CLASS(DShape2DTransform, false, false)
|
||||
|
||||
|
@ -677,6 +680,19 @@ void F2DDrawer::AddPoly(FGameTexture* img, FVector4* vt, size_t vtcount, unsigne
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
float F2DDrawer::GetClassicFlatScalarWidth()
|
||||
{
|
||||
float ar = 4.f / 3.f / (float)ActiveRatio((float)screen->GetWidth(), (float)screen->GetHeight());
|
||||
float sw = 320.f * classic_scaling_factor / (float)screen->GetWidth() / ar;
|
||||
return sw;
|
||||
}
|
||||
|
||||
float F2DDrawer::GetClassicFlatScalarHeight()
|
||||
{
|
||||
float sh = 240.f / classic_scaling_pixelaspect * classic_scaling_factor / (float)screen->GetHeight();
|
||||
return sh;
|
||||
}
|
||||
|
||||
void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTexture *src, int local_origin, double flatscale)
|
||||
{
|
||||
float fU1, fU2, fV1, fV2;
|
||||
|
@ -692,6 +708,10 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu
|
|||
|
||||
float fs = 1.f / float(flatscale);
|
||||
bool flipc = false;
|
||||
|
||||
float sw = GetClassicFlatScalarWidth();
|
||||
float sh = GetClassicFlatScalarHeight();
|
||||
|
||||
switch (local_origin)
|
||||
{
|
||||
case 0:
|
||||
|
@ -752,6 +772,19 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu
|
|||
fV1 = float(right - left) / (float)src->GetDisplayHeight() * fs;
|
||||
break;
|
||||
|
||||
case -1: // classic flat scaling
|
||||
fU1 = float(left) / (float)src->GetDisplayWidth() * fs * sw;
|
||||
fV1 = float(top) / (float)src->GetDisplayHeight() * fs * sh;
|
||||
fU2 = float(right) / (float)src->GetDisplayWidth() * fs * sw;
|
||||
fV2 = float(bottom) / (float)src->GetDisplayHeight() * fs * sh;
|
||||
break;
|
||||
|
||||
case -2: // classic scaling for screen bevel
|
||||
fU1 = 0;
|
||||
fV1 = 0;
|
||||
fU2 = float(right - left) / (float)src->GetDisplayWidth() * fs * sw;
|
||||
fV2 = float(bottom - top) / (float)src->GetDisplayHeight() * fs * sh;
|
||||
break;
|
||||
}
|
||||
dg.mVertIndex = (int)mVertices.Reserve(4);
|
||||
auto ptr = &mVertices[dg.mVertIndex];
|
||||
|
|
|
@ -174,6 +174,8 @@ private:
|
|||
void SetColorOverlay(PalEntry color, float alpha, PalEntry &vertexcolor, PalEntry &overlaycolor);
|
||||
|
||||
public:
|
||||
float GetClassicFlatScalarWidth();
|
||||
float GetClassicFlatScalarHeight();
|
||||
void AddTexture(FGameTexture* img, DrawParms& parms);
|
||||
void AddShape(FGameTexture *img, DShape2D *shape, DrawParms &parms);
|
||||
void AddPoly(FGameTexture *texture, FVector2 *points, int npoints,
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
EXTERN_CVAR(Int, vid_aspect)
|
||||
EXTERN_CVAR(Int, uiscale)
|
||||
CVAR(Bool, ui_screenborder_classic_scaling, true, CVAR_ARCHIVE)
|
||||
|
||||
// Helper for ActiveRatio and CheckRatio. Returns the forced ratio type, or -1 if none.
|
||||
int ActiveFakeRatio(int width, int height)
|
||||
|
@ -1161,10 +1162,11 @@ void FillBorder (F2DDrawer *drawer, FGameTexture *img)
|
|||
|
||||
if (img != NULL)
|
||||
{
|
||||
drawer->AddFlatFill(0, 0, Width, bordtop, img); // Top
|
||||
drawer->AddFlatFill(0, bordtop, bordleft, Height - bordbottom, img); // Left
|
||||
drawer->AddFlatFill(Width - bordright, bordtop, Width, Height - bordbottom, img); // Right
|
||||
drawer->AddFlatFill(0, Height - bordbottom, Width, Height, img); // Bottom
|
||||
int filltype = (ui_screenborder_classic_scaling) ? -1 : 0;
|
||||
drawer->AddFlatFill(0, 0, Width, bordtop, img, filltype); // Top
|
||||
drawer->AddFlatFill(0, bordtop, bordleft, Height - bordbottom, img, filltype); // Left
|
||||
drawer->AddFlatFill(Width - bordright, bordtop, Width, Height - bordbottom, img, filltype); // Right
|
||||
drawer->AddFlatFill(0, Height - bordbottom, Width, Height, img, filltype); // Bottom
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1351,9 +1353,10 @@ DEFINE_ACTION_FUNCTION(_Screen, Dim)
|
|||
|
||||
void DrawBorder (F2DDrawer *drawer, FTextureID picnum, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
int filltype = (ui_screenborder_classic_scaling) ? -1 : 0;
|
||||
if (picnum.isValid())
|
||||
{
|
||||
drawer->AddFlatFill (x1, y1, x2, y2, TexMan.GetGameTexture(picnum, false));
|
||||
drawer->AddFlatFill (x1, y1, x2, y2, TexMan.GetGameTexture(picnum, false), filltype);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -89,6 +89,8 @@ EXTERN_CVAR (Bool, noisedebug)
|
|||
EXTERN_CVAR (Int, con_scaletext)
|
||||
EXTERN_CVAR(Bool, vid_fps)
|
||||
EXTERN_CVAR(Bool, inter_subtitles)
|
||||
EXTERN_CVAR(Bool, ui_screenborder_classic_scaling)
|
||||
|
||||
CVAR(Int, hud_scale, 0, CVAR_ARCHIVE);
|
||||
CVAR(Bool, log_vgafont, false, CVAR_ARCHIVE)
|
||||
|
||||
|
@ -162,23 +164,53 @@ void V_DrawFrame(F2DDrawer* drawer, int left, int top, int width, int height)
|
|||
int right = left + width;
|
||||
int bottom = top + height;
|
||||
|
||||
// Draw top and bottom sides.
|
||||
p = TexMan.GetGameTextureByName(border->t);
|
||||
drawer->AddFlatFill(left, top - (int)p->GetDisplayHeight(), right, top, p, true);
|
||||
p = TexMan.GetGameTextureByName(border->b);
|
||||
drawer->AddFlatFill(left, bottom, right, bottom + (int)p->GetDisplayHeight(), p, true);
|
||||
float sw = drawer->GetClassicFlatScalarWidth();
|
||||
float sh = drawer->GetClassicFlatScalarHeight();
|
||||
|
||||
// Draw left and right sides.
|
||||
p = TexMan.GetGameTextureByName(border->l);
|
||||
drawer->AddFlatFill(left - (int)p->GetDisplayWidth(), top, left, bottom, p, true);
|
||||
p = TexMan.GetGameTextureByName(border->r);
|
||||
drawer->AddFlatFill(right, top, right + (int)p->GetDisplayWidth(), bottom, p, true);
|
||||
if (!ui_screenborder_classic_scaling)
|
||||
{
|
||||
// Draw top and bottom sides.
|
||||
p = TexMan.GetGameTextureByName(border->t);
|
||||
drawer->AddFlatFill(left, top - (int)p->GetDisplayHeight(), right, top, p, true);
|
||||
p = TexMan.GetGameTextureByName(border->b);
|
||||
drawer->AddFlatFill(left, bottom, right, bottom + (int)p->GetDisplayHeight(), p, true);
|
||||
|
||||
// Draw beveled corners.
|
||||
DrawTexture(drawer, TexMan.GetGameTextureByName(border->tl), left - offset, top - offset, TAG_DONE);
|
||||
DrawTexture(drawer, TexMan.GetGameTextureByName(border->tr), left + width, top - offset, TAG_DONE);
|
||||
DrawTexture(drawer, TexMan.GetGameTextureByName(border->bl), left - offset, top + height, TAG_DONE);
|
||||
DrawTexture(drawer, TexMan.GetGameTextureByName(border->br), left + width, top + height, TAG_DONE);
|
||||
// Draw left and right sides.
|
||||
p = TexMan.GetGameTextureByName(border->l);
|
||||
drawer->AddFlatFill(left - (int)p->GetDisplayWidth(), top, left, bottom, p, true);
|
||||
p = TexMan.GetGameTextureByName(border->r);
|
||||
drawer->AddFlatFill(right, top, right + (int)p->GetDisplayWidth(), bottom, p, true);
|
||||
|
||||
// Draw beveled corners.
|
||||
DrawTexture(drawer, TexMan.GetGameTextureByName(border->tl), left - offset, top - offset, TAG_DONE);
|
||||
DrawTexture(drawer, TexMan.GetGameTextureByName(border->tr), left + width, top - offset, TAG_DONE);
|
||||
DrawTexture(drawer, TexMan.GetGameTextureByName(border->bl), left - offset, top + height, TAG_DONE);
|
||||
DrawTexture(drawer, TexMan.GetGameTextureByName(border->br), left + width, top + height, TAG_DONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw top and bottom sides.
|
||||
p = TexMan.GetGameTextureByName(border->t);
|
||||
drawer->AddFlatFill(left, top - (int)(p->GetDisplayHeight() / sh), right, top, p, -2);
|
||||
p = TexMan.GetGameTextureByName(border->b);
|
||||
drawer->AddFlatFill(left, bottom, right, bottom + (int)(p->GetDisplayHeight() / sh), p, -2);
|
||||
|
||||
// Draw left and right sides.
|
||||
p = TexMan.GetGameTextureByName(border->l);
|
||||
drawer->AddFlatFill(left - (int)(p->GetDisplayWidth() / sw), top, left, bottom, p, -2);
|
||||
p = TexMan.GetGameTextureByName(border->r);
|
||||
drawer->AddFlatFill(right, top, right + (int)(p->GetDisplayWidth() / sw), bottom, p, -2);
|
||||
|
||||
// Draw beveled corners.
|
||||
p = TexMan.GetGameTextureByName(border->tl);
|
||||
drawer->AddFlatFill(left - (int)(p->GetDisplayWidth() / sw), top - (int)(p->GetDisplayHeight() / sh), left, top, p, -2);
|
||||
p = TexMan.GetGameTextureByName(border->tr);
|
||||
drawer->AddFlatFill(right, top - (int)(p->GetDisplayHeight() / sh), right + (int)(p->GetDisplayWidth() / sw), top, p, -2);
|
||||
p = TexMan.GetGameTextureByName(border->bl);
|
||||
drawer->AddFlatFill(left - (int)(p->GetDisplayWidth() / sw), bottom, left, bottom + (int)(p->GetDisplayHeight() / sh), p, -2);
|
||||
p = TexMan.GetGameTextureByName(border->br);
|
||||
drawer->AddFlatFill(right, bottom, right + (int)(p->GetDisplayWidth() / sw), bottom + (int)(p->GetDisplayHeight() / sh), p, -2);
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Screen, DrawFrame)
|
||||
|
@ -1038,6 +1070,8 @@ void DBaseStatusBar::RefreshBackground () const
|
|||
|
||||
auto tex = GetBorderTexture(primaryLevel);
|
||||
|
||||
float sh = twod->GetClassicFlatScalarHeight();
|
||||
|
||||
if(!CompleteBorder)
|
||||
{
|
||||
if(y < twod->GetHeight())
|
||||
|
@ -1070,9 +1104,18 @@ void DBaseStatusBar::RefreshBackground () const
|
|||
FGameTexture *p = TexMan.GetGameTextureByName(gameinfo.Border.b);
|
||||
if (p != NULL)
|
||||
{
|
||||
int h = int(0.5 + p->GetDisplayHeight());
|
||||
twod->AddFlatFill(0, y, x, y + h, p, true);
|
||||
twod->AddFlatFill(x2, y, twod->GetWidth(), y + h, p, true);
|
||||
if (!ui_screenborder_classic_scaling)
|
||||
{
|
||||
int h = int(0.5 + p->GetDisplayHeight());
|
||||
twod->AddFlatFill(0, y, x, y + h, p, true);
|
||||
twod->AddFlatFill(x2, y, twod->GetWidth(), y + h, p, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int h = (int)((0.5f + p->GetDisplayHeight()) / sh);
|
||||
twod->AddFlatFill(0, y, x, y + h, p, -2);
|
||||
twod->AddFlatFill(x2, y, twod->GetWidth(), y + h, p, -2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ extern int NoWipe;
|
|||
CVAR(Bool, nointerscrollabort, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||
CVAR(Bool, inter_subtitles, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||
|
||||
CVAR(Bool, inter_classic_scaling, true, CVAR_ARCHIVE);
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// This also gets used by the title loop.
|
||||
|
@ -221,7 +223,7 @@ void DIntermissionScreen::Drawer ()
|
|||
}
|
||||
else
|
||||
{
|
||||
twod->AddFlatFill(0,0, twod->GetWidth(), twod->GetHeight(), TexMan.GetGameTexture(mBackground));
|
||||
twod->AddFlatFill(0,0, twod->GetWidth(), twod->GetHeight(), TexMan.GetGameTexture(mBackground), (inter_classic_scaling ? -1 : 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue