From 62381cc7dedecd47e270c6c9241dd14bec79fa8f Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 19 Dec 2024 06:46:43 -0500 Subject: [PATCH] - fix 1:1.2 minimizer function to work with actual 4:3 screens --- src/common/rendering/r_videoscale.cpp | 29 ++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/common/rendering/r_videoscale.cpp b/src/common/rendering/r_videoscale.cpp index 6d11ff468a1..51f2844d12e 100644 --- a/src/common/rendering/r_videoscale.cpp +++ b/src/common/rendering/r_videoscale.cpp @@ -98,6 +98,33 @@ namespace { return (uint32_t)((float)inheight * v_MinimumToFill(inwidth, inheight)); } + + float v_MinimumToFill2(uint32_t inwidth, uint32_t inheight) + { + // sx = screen x dimension, sy = same for y + float sx = (float)inwidth * 1.2, sy = (float)inheight; + static float lastsx = 0., lastsy = 0., result = 0.; + if (lastsx != sx || lastsy != sy) + { + if (sx <= 0. || sy <= 0.) + return 1.; // prevent x/0 error + // set absolute minimum scale to fill the entire screen but get as close to 640x400 as possible + float ssx = (float)(VID_MIN_UI_WIDTH) / 1.2 / sx, ssy = (float)(VID_MIN_UI_HEIGHT) / sy; + result = (ssx < ssy) ? ssy : ssx; + lastsx = sx; + lastsy = sy; + } + return result; + } + inline uint32_t v_mfillX2(uint32_t inwidth, uint32_t inheight) + { + return (uint32_t)((float)inwidth * v_MinimumToFill2(inwidth, inheight) * 1.2); + } + inline uint32_t v_mfillY2(uint32_t inwidth, uint32_t inheight) + { + return (uint32_t)((float)inheight * v_MinimumToFill2(inwidth, inheight)); + } + inline void refresh_minimums() { // specialUI is tracking a state where high-res console fonts are actually required, and @@ -138,7 +165,7 @@ namespace { true, [](uint32_t Width, uint32_t Height)->uint32_t { return 1280; }, [](uint32_t Width, uint32_t Height)->uint32_t { return 800; }, 1.2f, false }, // 4 - 1280x800 { true, [](uint32_t Width, uint32_t Height)->uint32_t { return vid_scale_customwidth; }, [](uint32_t Width, uint32_t Height)->uint32_t { return vid_scale_customheight; }, 1.0f, true }, // 5 - Custom { true, [](uint32_t Width, uint32_t Height)->uint32_t { return 320; }, [](uint32_t Width, uint32_t Height)->uint32_t { return 200; }, 1.2f, false }, // 6 - 320x200 - { true, [](uint32_t Width, uint32_t Height)->uint32_t { return v_mfillX(Width * 1.2, Height) * 1.2; }, [](uint32_t Width, uint32_t Height)->uint32_t { return v_mfillY(Width * 1.2, Height); }, 1.2f, false }, // 7 - Minimum Scale to Fill Entire Screen (1.2) + { true, [](uint32_t Width, uint32_t Height)->uint32_t { return v_mfillX2(Width, Height) * 1.2; }, [](uint32_t Width, uint32_t Height)->uint32_t { return v_mfillY2(Width, Height); }, 1.2f, false }, // 7 - Minimum Scale to Fill Entire Screen (1.2) }; bool isOutOfBounds(int x) {