mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 09:21:36 +00:00
New CON command 'showviewunbiased', mapping the screen coords w/o round-to-0 bias.
The showview command transforms the 320-based screen bound coordinates to the real screen bounds like xreal = (x*xdim)/320, which shows a bias towards zero: for example, for a 1680 screen width, the maximum permissible value 319 is mapped to round_to_zero((319*1680)/320) == 1674. (The rounding is implicit in the integer division). This makes it impossible for a view to cover the whole screen with any other resolution than 320x200. The new command transforms the bounds like xreal = (x*(xdim-1))/319, which would map 319 to 1679 in the preceding example. git-svn-id: https://svn.eduke32.com/eduke32@2573 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
5b036273c9
commit
1ae1bfa479
3 changed files with 29 additions and 4 deletions
|
@ -87,6 +87,7 @@ static struct { uint32_t keyw; uint32_t date; } g_keywdate[] =
|
|||
{ CON_INCLUDEDEFAULT, 20110615 },
|
||||
{ CON_SETACTORSOUNDPITCH, 20111102 },
|
||||
{ CON_ECHO, 20120304 },
|
||||
{ CON_SHOWVIEWUNBIASED, 20120331 },
|
||||
};
|
||||
|
||||
char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling
|
||||
|
@ -565,6 +566,7 @@ const char *keyw[] =
|
|||
"includedefault", // 360
|
||||
"setactorsoundpitch", // 361
|
||||
"echo", // 362
|
||||
"showviewunbiased", // 363
|
||||
"<null>"
|
||||
};
|
||||
|
||||
|
@ -4220,6 +4222,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
|||
continue;
|
||||
|
||||
case CON_SHOWVIEW:
|
||||
case CON_SHOWVIEWUNBIASED:
|
||||
if (g_parsingEventPtr == NULL && g_processingState == 0)
|
||||
{
|
||||
C_ReportError(ERROR_EVENTONLY);
|
||||
|
|
|
@ -941,6 +941,7 @@ enum ScriptKeywords_t
|
|||
CON_INCLUDEDEFAULT, // 360
|
||||
CON_SETACTORSOUNDPITCH, // 361
|
||||
CON_ECHO, // 362
|
||||
CON_SHOWVIEWUNBIASED, // 363
|
||||
CON_END
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -2310,6 +2310,7 @@ nullquote:
|
|||
}
|
||||
|
||||
case CON_SHOWVIEW:
|
||||
case CON_SHOWVIEWUNBIASED:
|
||||
insptr++;
|
||||
{
|
||||
int32_t x=Gv_GetVarX(*insptr++);
|
||||
|
@ -2318,10 +2319,10 @@ nullquote:
|
|||
int32_t a=Gv_GetVarX(*insptr++);
|
||||
int32_t horiz=Gv_GetVarX(*insptr++);
|
||||
int32_t sect=Gv_GetVarX(*insptr++);
|
||||
int32_t x1=scale(Gv_GetVarX(*insptr++),xdim,320);
|
||||
int32_t y1=scale(Gv_GetVarX(*insptr++),ydim,200);
|
||||
int32_t x2=scale(Gv_GetVarX(*insptr++),xdim,320);
|
||||
int32_t y2=scale(Gv_GetVarX(*insptr++),ydim,200);
|
||||
int32_t x1=Gv_GetVarX(*insptr++);
|
||||
int32_t y1=Gv_GetVarX(*insptr++);
|
||||
int32_t x2=Gv_GetVarX(*insptr++);
|
||||
int32_t y2=Gv_GetVarX(*insptr++);
|
||||
int32_t smoothratio = min(max((totalclock - ototalclock) * (65536 / 4),0),65536);
|
||||
#ifdef USE_OPENGL
|
||||
int32_t oprojhacks;
|
||||
|
@ -2332,6 +2333,26 @@ nullquote:
|
|||
if (x1 > x2) swaplong(&x1,&x2);
|
||||
if (y1 > y2) swaplong(&y1,&y2);
|
||||
|
||||
if (tw == CON_SHOWVIEW)
|
||||
{
|
||||
// The showview command has a rounding bias towards zero,
|
||||
// e.g. floor((319*1680)/320) == 1674
|
||||
x1 = scale(x1,xdim,320);
|
||||
y1 = scale(y1,ydim,200);
|
||||
x2 = scale(x2,xdim,320);
|
||||
y2 = scale(y2,ydim,200);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This will map the maximum 320-based coordinate to the
|
||||
// maximum real screen coordinate:
|
||||
// floor((319*1679)/319) == 1679
|
||||
x1 = scale(x1,xdim-1,319);
|
||||
y1 = scale(y1,ydim-1,199);
|
||||
x2 = scale(x2,xdim-1,319);
|
||||
y2 = scale(y2,ydim-1,199);
|
||||
}
|
||||
|
||||
if ((x1 < 0 || y1 < 0 || x2 > xdim-1 || y2 > ydim-1 || x2-x1 < 2 || y2-y1 < 2))
|
||||
{
|
||||
OSD_Printf(CON_ERROR "incorrect coordinates\n",g_errorLineNum,keyw[g_tw]);
|
||||
|
|
Loading…
Reference in a new issue