- implement vid_scalemode = 6 - sets absolute minimum scaling to fill entire screen - useful for speeding up software rendering

This commit is contained in:
Rachael Alexanderson 2019-12-20 03:04:56 -05:00
parent 318da33e39
commit a53652f36e

View file

@ -27,7 +27,7 @@
#include "v_video.h"
#include "templates.h"
#define NUMSCALEMODES 6
#define NUMSCALEMODES 7
extern bool setsizeneeded;
@ -61,6 +61,33 @@ namespace
bool isScaled43;
bool isCustom;
};
float v_MinimumToFill()
{
// sx = screen x dimension, sy = same for y
float sx = (float)screen->GetClientWidth(), sy = (float)screen->GetClientHeight();
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 = 640. / sx, ssy = 400. / sy;
result = (ssx < ssy) ? ssy : ssx;
lastsx = sx;
lastsy = sy;
}
return result;
}
inline uint32_t v_mfillX()
{
return screen ? (uint32_t)((float)screen->GetClientWidth() * v_MinimumToFill()) : 640;
}
inline uint32_t v_mfillY()
{
return screen ? (uint32_t)((float)screen->GetClientHeight() * v_MinimumToFill()) : 400;
}
v_ScaleTable vScaleTable[NUMSCALEMODES] =
{
// isValid, isLinear, GetScaledWidth(), GetScaledHeight(), isScaled43, isCustom
@ -68,8 +95,9 @@ namespace
{ true, true, [](uint32_t Width)->uint32_t { return Width; }, [](uint32_t Height)->uint32_t { return Height; }, false, false }, // 1 - Native (Linear)
{ true, false, [](uint32_t Width)->uint32_t { return 640; }, [](uint32_t Height)->uint32_t { return 400; }, true, false }, // 2 - 640x400 (formerly 320x200)
{ true, true, [](uint32_t Width)->uint32_t { return 960; }, [](uint32_t Height)->uint32_t { return 600; }, true, false }, // 3 - 960x600 (formerly 640x400)
{ true, true, [](uint32_t Width)->uint32_t { return 1280; }, [](uint32_t Height)->uint32_t { return 800; }, true, false }, // 4 - 1280x800
{ true, true, [](uint32_t Width)->uint32_t { return 1280; }, [](uint32_t Height)->uint32_t { return 800; }, true, false }, // 4 - 1280x800
{ true, true, [](uint32_t Width)->uint32_t { return vid_scale_customwidth; }, [](uint32_t Height)->uint32_t { return vid_scale_customheight; }, true, true }, // 5 - Custom
{ true, true, [](uint32_t Width)->uint32_t { return v_mfillX(); }, [](uint32_t Height)->uint32_t { return v_mfillY(); }, false, false }, // 6 - Minimum Scale to Fill Entire Screen
};
bool isOutOfBounds(int x)
{