From e0b2497a5621e8bfc64c8ccf57c68ca99328e8a8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 21 Apr 2020 21:26:33 +0200 Subject: [PATCH] - backend update. --- source/common/2d/v_draw.cpp | 6 ++++++ source/common/2d/v_draw.h | 36 +++++++++++++++++++++++++++++++ source/core/rendering/v_video.cpp | 6 ------ source/core/rendering/v_video.h | 4 ---- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/source/common/2d/v_draw.cpp b/source/common/2d/v_draw.cpp index a85f1ac8a..bf33d6f6a 100644 --- a/source/common/2d/v_draw.cpp +++ b/source/common/2d/v_draw.cpp @@ -1384,3 +1384,9 @@ void DrawFrame(F2DDrawer* twod, PalEntry color, int left, int top, int width, in twod->AddColorOnlyQuad(right, top - offset, offset, height + 2 * offset, color); } +void V_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int* cleanx, int* cleany, int* _cx1, int* _cx2) +{ + if (designheight < 240 && realheight >= 480) designheight = 240; + *cleanx = *cleany = std::min(realwidth / designwidth, realheight / designheight); +} + diff --git a/source/common/2d/v_draw.h b/source/common/2d/v_draw.h index e42b6f306..fe76272f5 100644 --- a/source/common/2d/v_draw.h +++ b/source/common/2d/v_draw.h @@ -233,3 +233,39 @@ void VirtualToRealCoordsInt(F2DDrawer* drawer, int& x, int& y, int& w, int& h, i extern int CleanWidth, CleanHeight, CleanXfac, CleanYfac; extern int CleanWidth_1, CleanHeight_1, CleanXfac_1, CleanYfac_1; + +void V_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int* cleanx, int* cleany, int* cx1 = NULL, int* cx2 = NULL); + +class ScaleOverrider +{ + int savedxfac, savedyfac, savedwidth, savedheight; + +public: + // This is to allow certain elements to use an optimal fullscreen scale which for the menu would be too large. + // The old code contained far too much mess to compensate for the menus which negatively affected everything else. + // However, for compatibility reasons the currently used variables cannot be changed so they have to be overridden temporarily. + // This class provides a safe interface for this because it ensures that the values get restored afterward. + // Currently, the intermission and the level summary screen use this. + ScaleOverrider(F2DDrawer *drawer) + { + savedxfac = CleanXfac; + savedyfac = CleanYfac; + savedwidth = CleanWidth; + savedheight = CleanHeight; + + if (drawer) + { + V_CalcCleanFacs(320, 200, drawer->GetWidth(), drawer->GetHeight(), &CleanXfac, &CleanYfac); + CleanWidth = drawer->GetWidth() / CleanXfac; + CleanHeight = drawer->GetHeight() / CleanYfac; + } + } + + ~ScaleOverrider() + { + CleanXfac = savedxfac; + CleanYfac = savedyfac; + CleanWidth = savedwidth; + CleanHeight = savedheight; + } +}; diff --git a/source/core/rendering/v_video.cpp b/source/core/rendering/v_video.cpp index b8e4d22fa..85c0d799f 100644 --- a/source/core/rendering/v_video.cpp +++ b/source/core/rendering/v_video.cpp @@ -298,12 +298,6 @@ void V_OutputResized (int width, int height) C_NewModeAdjust(); } -void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany, int *_cx1, int *_cx2) -{ - if (designheight < 240 && realheight >= 480) designheight = 240; - *cleanx = *cleany = std::min(realwidth / designwidth, realheight / designheight); -} - bool IVideo::SetResolution () { DFrameBuffer *buff = CreateFrameBuffer(); diff --git a/source/core/rendering/v_video.h b/source/core/rendering/v_video.h index aefb66f09..26aa349b3 100644 --- a/source/core/rendering/v_video.h +++ b/source/core/rendering/v_video.h @@ -38,9 +38,6 @@ #include "basics.h" #include "vectors.h" #include "m_png.h" - -//#include "doomdef.h" -//#include "dobject.h" #include "renderstyle.h" #include "c_cvars.h" #include "v_2ddrawer.h" @@ -118,7 +115,6 @@ extern int DisplayWidth, DisplayHeight; void V_UpdateModeSize (int width, int height); void V_OutputResized (int width, int height); -void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany, int *cx1=NULL, int *cx2=NULL); EXTERN_CVAR(Int, vid_rendermode) EXTERN_CVAR(Bool, vid_fullscreen)