Skip to content

Commit

Permalink
- removed scale resolutions and added vid_scalefactor to replace them.
Browse files Browse the repository at this point in the history
  • Loading branch information
madame-rachelle committed Sep 10, 2017
1 parent 0924cc3 commit 4b82bb5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
29 changes: 15 additions & 14 deletions src/r_videoscale.cpp
Expand Up @@ -25,7 +25,7 @@
#include "c_dispatch.h"
#include "c_cvars.h"

#define NUMSCALEMODES 11
#define NUMSCALEMODES 5

namespace
{
Expand All @@ -41,19 +41,19 @@ namespace
{
// isValid, isLinear, GetScaledWidth(), GetScaledHeight(), isScaled43
{ true, false, [](uint32_t Width)->uint32_t { return Width; }, [](uint32_t Height)->uint32_t { return Height; }, false }, // 0 - Native
{ true, false, [](uint32_t Width)->uint32_t { return 320; }, [](uint32_t Height)->uint32_t { return 200; }, true }, // 1 - 320x200
{ true, true, [](uint32_t Width)->uint32_t { return 640; }, [](uint32_t Height)->uint32_t { return 400; }, true }, // 2 - 640x400
{ true, true, [](uint32_t Width)->uint32_t { return 1280; }, [](uint32_t Height)->uint32_t { return 800; }, true }, // 3 - 1280x800
{ false, false, nullptr, nullptr, false }, // 4
{ false, false, nullptr, nullptr, false }, // 5
{ false, false, nullptr, nullptr, false }, // 6
{ false, false, nullptr, nullptr, false }, // 7
{ true, false, [](uint32_t Width)->uint32_t { return Width / 2; }, [](uint32_t Height)->uint32_t { return Height / 2; }, false }, // 8 - Half-Res
{ true, true, [](uint32_t Width)->uint32_t { return Width * 0.75; }, [](uint32_t Height)->uint32_t { return Height * 0.75; }, false }, // 9 - Res * 0.75
{ true, true, [](uint32_t Width)->uint32_t { return Width * 2; }, [](uint32_t Height)->uint32_t { return Height * 2; }, false }, // 10 - SSAAx2
{ true, true, [](uint32_t Width)->uint32_t { return Width; }, [](uint32_t Height)->uint32_t { return Height; }, false }, // 1 - Native (Linear)
{ true, false, [](uint32_t Width)->uint32_t { return 320; }, [](uint32_t Height)->uint32_t { return 200; }, true }, // 2 - 320x200
{ true, false, [](uint32_t Width)->uint32_t { return 640; }, [](uint32_t Height)->uint32_t { return 400; }, true }, // 3 - 640x400
{ true, true, [](uint32_t Width)->uint32_t { return 1280; }, [](uint32_t Height)->uint32_t { return 800; }, true }, // 4 - 1280x800
};
}

CUSTOM_CVAR(Float, vid_scalefactor, 1.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
if (self <= 0.0 || self > 2.0)
self = 1.0;
}

CUSTOM_CVAR(Int, vid_scalemode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
if (self < 0 || self >= NUMSCALEMODES || vScaleTable[self].isValid == false)
Expand All @@ -64,17 +64,18 @@ CUSTOM_CVAR(Int, vid_scalemode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)

bool ViewportLinearScale()
{
return vScaleTable[vid_scalemode].isLinear;
// vid_scalefactor > 1 == forced linear scale
return (vid_scalefactor > 1.0) ? true : vScaleTable[vid_scalemode].isLinear;
}

int ViewportScaledWidth(int width)
{
return vScaleTable[vid_scalemode].GetScaledWidth(width);
return vScaleTable[vid_scalemode].GetScaledWidth((int)((float)width * vid_scalefactor));
}

int ViewportScaledHeight(int height)
{
return vScaleTable[vid_scalemode].GetScaledHeight(height);
return vScaleTable[vid_scalemode].GetScaledHeight((int)((float)height * vid_scalefactor));
}

bool ViewportIsScaled43()
Expand Down
3 changes: 3 additions & 0 deletions wadsrc/static/language.enu
Expand Up @@ -2193,6 +2193,7 @@ VIDMNU_ASPECTRATIO = "Aspect ratio";
VIDMNU_FORCEASPECT = "Force aspect ratio";
VIDMNU_5X4ASPECTRATIO = "Enable 5:4 aspect ratio";
VIDMNU_SCALEMODE = "Resolution scale";
VIDMNU_SCALEFACTOR = "Scale Factor";
VIDMNU_ENTERTEXT = "Press ENTER to set mode";
VIDMNU_TESTTEXT1 = "T to test mode for 5 seconds";
VIDMNU_TESTTEXT2 = "Please wait 5 seconds...";
Expand Down Expand Up @@ -2378,6 +2379,8 @@ OPTVAL_VTFZDOOM = "ZDoom (Forced)";
OPTVAL_VTFVANILLA = "Vanilla (Forced)";
OPTVAL_VTAZDOOM = "Auto (ZDoom Preferred)";
OPTVAL_VTAVANILLA = "Auto (Vanilla Preferred)";
OPTVAL_SCALENEAREST = "Scaled (Nearest)";
OPTVAL_SCALELINEAR = "Scaled (Linear)";

// Colors
C_BRICK = "\cabrick";
Expand Down
13 changes: 6 additions & 7 deletions wadsrc/static/menudef.txt
Expand Up @@ -1858,13 +1858,11 @@ OptionValue RatiosTFT
}
OptionValue ScaleModes
{
0, "$OPTVAL_OFF"
1, "320x200"
2, "640x400"
3, "1280x800"
8, "0.5x"
9, "0.75x"
10, "2x SSAA"
0, "$OPTVAL_SCALENEAREST"
1, "$OPTVAL_SCALELINEAR"
2, "320x200"
3, "640x400"
4, "1280x800"
}

OptionMenu VideoModeMenu protected
Expand All @@ -1880,6 +1878,7 @@ OptionMenu VideoModeMenu protected
Option "$VIDMNU_FORCEASPECT", "vid_aspect", "ForceRatios"
Option "$VIDMNU_5X4ASPECTRATIO", "vid_tft", "YesNo"
Option "$VIDMNU_SCALEMODE", "vid_scalemode", "ScaleModes"
Slider "$VIDMNU_SCALEFACTOR", "vid_scalefactor", 0.25, 2.0, 0.25, 2
StaticText " "
ScreenResolution "res_0"
ScreenResolution "res_1"
Expand Down

0 comments on commit 4b82bb5

Please sign in to comment.