mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- implement a new vid_scalemode: 5 - this allows the usage of custom absolute scaling modes
- new ccmd: vid_setscale <x> <y> [linear] [fake-mcga-4:3] - sets vid_scalemode to 5 with the absolute scaling parameters. example: vid_scalemode 800 600 allows you to see the screen (stretched) as if it were 800x600. Linear specifies whether to force the scaling to be linear in this mode, and "fake-mcga-4:3" is meant for 320x200-like modes that mimic mode13h scaling.
This commit is contained in:
parent
156ed5790e
commit
d7b7ae06e7
2 changed files with 60 additions and 8 deletions
|
@ -2,7 +2,7 @@
|
|||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 2017 Magnus Norddahl
|
||||
// Copyright(C) 2017 Rachael Alexanderson
|
||||
// Copyright(C) 2018 Rachael Alexanderson
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
@ -26,7 +26,14 @@
|
|||
#include "c_cvars.h"
|
||||
#include "v_video.h"
|
||||
|
||||
#define NUMSCALEMODES 5
|
||||
#define NUMSCALEMODES 6
|
||||
|
||||
EXTERN_CVAR(Int, vid_scalemode)
|
||||
EXTERN_CVAR(Int, vid_aspect)
|
||||
CVAR(Int, vid_scale_customwidth, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Int, vid_scale_customheight, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, vid_scale_customlinear, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, vid_scale_customstretched, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -37,18 +44,22 @@ namespace
|
|||
uint32_t(*GetScaledWidth)(uint32_t Width);
|
||||
uint32_t(*GetScaledHeight)(uint32_t Height);
|
||||
bool isScaled43;
|
||||
bool isCustom;
|
||||
};
|
||||
v_ScaleTable vScaleTable[NUMSCALEMODES] =
|
||||
{
|
||||
// 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, 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
|
||||
// isValid, isLinear, GetScaledWidth(), GetScaledHeight(), isScaled43, isCustom
|
||||
{ true, false, [](uint32_t Width)->uint32_t { return Width; }, [](uint32_t Height)->uint32_t { return Height; }, false, false }, // 0 - Native
|
||||
{ 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 320; }, [](uint32_t Height)->uint32_t { return 200; }, true, false }, // 2 - 320x200
|
||||
{ true, false, [](uint32_t Width)->uint32_t { return 640; }, [](uint32_t Height)->uint32_t { return 400; }, true, false }, // 3 - 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 vid_scale_customwidth; }, [](uint32_t Height)->uint32_t { return vid_scale_customheight; }, true, true }, // 5 - Custom
|
||||
};
|
||||
bool isOutOfBounds(int x)
|
||||
{
|
||||
if (vScaleTable[vid_scalemode].isCustom)
|
||||
return ((vid_scale_customwidth < 80) || (vid_scale_customheight < 50));
|
||||
return (x < 0 || x >= NUMSCALEMODES || vScaleTable[x].isValid == false);
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +82,9 @@ bool ViewportLinearScale()
|
|||
{
|
||||
if (isOutOfBounds(vid_scalemode))
|
||||
vid_scalemode = 0;
|
||||
// hack - use custom scaling if in "custom" mode
|
||||
if (vScaleTable[vid_scalemode].isCustom)
|
||||
return vid_scale_customlinear;
|
||||
// vid_scalefactor > 1 == forced linear scale
|
||||
return (vid_scalefactor > 1.0) ? true : vScaleTable[vid_scalemode].isLinear;
|
||||
}
|
||||
|
@ -97,6 +111,9 @@ bool ViewportIsScaled43()
|
|||
{
|
||||
if (isOutOfBounds(vid_scalemode))
|
||||
vid_scalemode = 0;
|
||||
// hack - use custom scaling if in "custom" mode
|
||||
if (vScaleTable[vid_scalemode].isCustom)
|
||||
return vid_scale_customstretched;
|
||||
return vScaleTable[vid_scalemode].isScaled43;
|
||||
}
|
||||
|
||||
|
@ -114,6 +131,11 @@ bool R_CalcsShouldBeBlocked()
|
|||
Printf("vid_scalemode should be 0 or 1 before using this command.\n");
|
||||
return true;
|
||||
}
|
||||
if (vid_aspect != 0 && vid_cropaspect == true)
|
||||
{ // just warn ... I'm not going to fix this, it's a pretty niche condition anyway.
|
||||
Printf("Warning: Using this command while vid_aspect is not 0 will yield results based on FULL screen geometry, NOT cropped!.\n");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -143,3 +165,32 @@ CCMD (vid_scaletoheight)
|
|||
|
||||
R_ShowCurrentScaling();
|
||||
}
|
||||
|
||||
inline bool atob(char* I)
|
||||
{
|
||||
if (stricmp (I, "true") == 0 || stricmp (I, "1") == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
CCMD (vid_setscale)
|
||||
{
|
||||
if (argv.argc() > 2)
|
||||
{
|
||||
vid_scale_customwidth = atoi(argv[1]);
|
||||
vid_scale_customheight = atoi(argv[2]);
|
||||
if (argv.argc() > 3)
|
||||
{
|
||||
vid_scale_customlinear = atob(argv[3]);
|
||||
if (argv.argc() > 4)
|
||||
{
|
||||
vid_scale_customstretched = atob(argv[4]);
|
||||
}
|
||||
}
|
||||
vid_scalemode = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf("Usage: vid_setscale <x> <y> [bool linear] [bool long-pixel-shape]\nThis command will create a custom viewport scaling mode.\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1903,6 +1903,7 @@ OptionValue ScaleModes
|
|||
2, "320x200"
|
||||
3, "640x400"
|
||||
4, "1280x800"
|
||||
5, "$OPTVAL_CUSTOM"
|
||||
}
|
||||
OptionValue CropAspect
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue