mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-02-09 09:40:57 +00:00
Match HWR_DrawFixedPatch to V_DrawFixedPatch
This commit is contained in:
parent
1b3e1f78af
commit
7764a1bb5d
1 changed files with 82 additions and 21 deletions
|
@ -147,10 +147,7 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
|
||||||
// | /|
|
// | /|
|
||||||
// |/ |
|
// |/ |
|
||||||
// 0--1
|
// 0--1
|
||||||
float sdupx = FIXED_TO_FLOAT(vid.fdupx)*2.0f;
|
float dupx, dupy, fscale, fwidth, fheight;
|
||||||
float sdupy = FIXED_TO_FLOAT(vid.fdupy)*2.0f;
|
|
||||||
float pdupx = FIXED_TO_FLOAT(vid.fdupx)*2.0f*FIXED_TO_FLOAT(pscale);
|
|
||||||
float pdupy = FIXED_TO_FLOAT(vid.fdupy)*2.0f*FIXED_TO_FLOAT(pscale);
|
|
||||||
|
|
||||||
if (alphalevel >= 10 && alphalevel < 13)
|
if (alphalevel >= 10 && alphalevel < 13)
|
||||||
return;
|
return;
|
||||||
|
@ -161,40 +158,104 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
|
||||||
else
|
else
|
||||||
HWR_GetMappedPatch(gpatch, colormap);
|
HWR_GetMappedPatch(gpatch, colormap);
|
||||||
|
|
||||||
|
dupx = (float)vid.dupx;
|
||||||
|
dupy = (float)vid.dupy;
|
||||||
|
|
||||||
switch (option & V_SCALEPATCHMASK)
|
switch (option & V_SCALEPATCHMASK)
|
||||||
{
|
{
|
||||||
case V_NOSCALEPATCH:
|
case V_NOSCALEPATCH:
|
||||||
pdupx = pdupy = 2.0f;
|
dupx = dupy = 1.0f;
|
||||||
break;
|
break;
|
||||||
case V_SMALLSCALEPATCH:
|
case V_SMALLSCALEPATCH:
|
||||||
pdupx = 2.0f * FIXED_TO_FLOAT(vid.fsmalldupx);
|
dupx = (float)vid.smalldupx;
|
||||||
pdupy = 2.0f * FIXED_TO_FLOAT(vid.fsmalldupy);
|
dupy = (float)vid.smalldupy;
|
||||||
break;
|
break;
|
||||||
case V_MEDSCALEPATCH:
|
case V_MEDSCALEPATCH:
|
||||||
pdupx = 2.0f * FIXED_TO_FLOAT(vid.fmeddupx);
|
dupx = (float)vid.meddupx;
|
||||||
pdupy = 2.0f * FIXED_TO_FLOAT(vid.fmeddupy);
|
dupy = (float)vid.meddupy;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option & V_NOSCALESTART)
|
dupx = dupy = (dupx < dupy ? dupx : dupy);
|
||||||
sdupx = sdupy = 2.0f;
|
fscale = FIXED_TO_FLOAT(pscale);
|
||||||
|
|
||||||
if (option & V_SPLITSCREEN)
|
if (option & V_OFFSET)
|
||||||
sdupy /= 2.0f;
|
|
||||||
|
|
||||||
if (option & V_FLIP) // Need to flip both this and sow
|
|
||||||
{
|
{
|
||||||
v[0].x = v[3].x = (cx*sdupx-(gpatch->width-gpatch->leftoffset)*pdupx)/vid.width - 1;
|
cx -= (float)gpatch->leftoffset * dupx * fscale;
|
||||||
v[2].x = v[1].x = (cx*sdupx+gpatch->leftoffset*pdupx)/vid.width - 1;
|
cy -= (float)gpatch->topoffset * dupy * fscale;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
v[0].x = v[3].x = (cx*sdupx-gpatch->leftoffset*pdupx)/vid.width - 1;
|
cy -= (float)gpatch->topoffset * fscale;
|
||||||
v[2].x = v[1].x = (cx*sdupx+(gpatch->width-gpatch->leftoffset)*pdupx)/vid.width - 1;
|
if (option & V_FLIP)
|
||||||
|
cx -= ((float)gpatch->width - (float)gpatch->leftoffset) * fscale;
|
||||||
|
else
|
||||||
|
cx -= (float)gpatch->leftoffset * fscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
v[0].y = v[1].y = 1-(cy*sdupy-gpatch->topoffset*pdupy)/vid.height;
|
if (option & V_SPLITSCREEN)
|
||||||
v[2].y = v[3].y = 1-(cy*sdupy+(gpatch->height-gpatch->topoffset)*pdupy)/vid.height;
|
cy /= 2;
|
||||||
|
|
||||||
|
if (!(option & V_NOSCALESTART))
|
||||||
|
{
|
||||||
|
cx = cx * dupx;
|
||||||
|
cy = cy * dupy;
|
||||||
|
|
||||||
|
if (!(option & V_SCALEPATCHMASK))
|
||||||
|
{
|
||||||
|
// centre screen
|
||||||
|
if (vid.width != BASEVIDWIDTH * vid.dupx)
|
||||||
|
{
|
||||||
|
if (option & V_SNAPTORIGHT)
|
||||||
|
cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx));
|
||||||
|
else if (!(option & V_SNAPTOLEFT))
|
||||||
|
cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/2;
|
||||||
|
}
|
||||||
|
if (vid.height != BASEVIDHEIGHT * vid.dupy)
|
||||||
|
{
|
||||||
|
if ((option & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM))
|
||||||
|
cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy));
|
||||||
|
else if (option & V_SNAPTOBOTTOM)
|
||||||
|
cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy));
|
||||||
|
else if (!(option & V_SNAPTOTOP))
|
||||||
|
cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy))/2;
|
||||||
|
}
|
||||||
|
// if it's meant to cover the whole screen, black out the rest
|
||||||
|
// TODO
|
||||||
|
/*if (x == 0 && SHORT(gpatch->width) == BASEVIDWIDTH && y == 0 && SHORT(gpatch->height) == BASEVIDHEIGHT)
|
||||||
|
{
|
||||||
|
const column_t *column = (const column_t *)((const UINT8 *)((patch_t *)gpatch) + LONG(((patch_t *)gpatch)->columnofs[0]));
|
||||||
|
const UINT8 *source = (const UINT8 *)(column) + 3;
|
||||||
|
HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0]));
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pscale != FRACUNIT)
|
||||||
|
{
|
||||||
|
fwidth = (float)gpatch->width * fscale * dupx;
|
||||||
|
fheight = (float)gpatch->height * fscale * dupy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fwidth = (float)gpatch->width * dupx;
|
||||||
|
fheight = (float)gpatch->height * dupy;
|
||||||
|
}
|
||||||
|
|
||||||
|
// positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1
|
||||||
|
cx = -1 + (cx / (vid.width/2));
|
||||||
|
cy = 1 - (cy / (vid.height/2));
|
||||||
|
|
||||||
|
// fwidth and fheight are similar
|
||||||
|
fwidth /= vid.width / 2;
|
||||||
|
fheight /= vid.height / 2;
|
||||||
|
|
||||||
|
// set the polygon vertices to the right positions
|
||||||
|
v[0].x = v[3].x = cx;
|
||||||
|
v[2].x = v[1].x = cx + fwidth;
|
||||||
|
|
||||||
|
v[0].y = v[1].y = cy;
|
||||||
|
v[2].y = v[3].y = cy - fheight;
|
||||||
|
|
||||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue