mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-04-19 16:51:53 +00:00
Merge branch 'drawflatfill-gl-fix' into 'next'
Drawflatfill gl fix See merge request STJr/SRB2!2655
This commit is contained in:
commit
c4fee7bea3
1 changed files with 52 additions and 19 deletions
|
@ -598,43 +598,76 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
|
|||
|
||||
// --------------------------------------------------------------------------
|
||||
// Fills a box of pixels using a flat texture as a pattern
|
||||
// Fixed to properly align like the other draw functions -luigi budd
|
||||
// --------------------------------------------------------------------------
|
||||
void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum)
|
||||
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum)
|
||||
{
|
||||
FOutVector v[4];
|
||||
const size_t len = W_LumpLength(flatlumpnum);
|
||||
UINT16 flatflag = R_GetFlatSize(len) - 1;
|
||||
double dflatsize = (double)(flatflag + 1);
|
||||
UINT16 flatflag = R_GetFlatSize(len);
|
||||
double dflatsize = (double)(flatflag);
|
||||
|
||||
// compilers are COOL!
|
||||
float dup = (float)vid.dup;
|
||||
float fx = (float)x * dup;
|
||||
float fy = (float)y * dup;
|
||||
float fw = (float)w * dup;
|
||||
float fh = (float)h * dup;
|
||||
|
||||
/*
|
||||
fx *= dup;
|
||||
fy *= dup;
|
||||
fw *= dup;
|
||||
fh *= dup;
|
||||
*/
|
||||
|
||||
if (fw <= 0 || fh <= 0)
|
||||
return;
|
||||
|
||||
if (fabsf((float)vid.width - (float)BASEVIDWIDTH * vid.dup) > 1.0E-36f)
|
||||
{
|
||||
fx += ((float)vid.width - ((float)BASEVIDWIDTH * vid.dup)) / 2;
|
||||
}
|
||||
if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * vid.dup) > 1.0E-36f)
|
||||
{
|
||||
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * vid.dup)) / 2;
|
||||
}
|
||||
|
||||
if (fx >= vid.width || fy >= vid.height)
|
||||
return;
|
||||
|
||||
fx = -1.0f + (fx / (vid.width / 2.0f));
|
||||
fy = 1.0f - (fy / (vid.height / 2.0f));
|
||||
fw /= vid.width / 2;
|
||||
fh /= vid.height / 2;
|
||||
|
||||
// 3--2
|
||||
// | /|
|
||||
// |/ |
|
||||
// 0--1
|
||||
|
||||
// position vertices
|
||||
v[0].x = v[3].x = fx;
|
||||
v[2].x = v[1].x = fx + fw;
|
||||
|
||||
v[0].x = v[3].x = (x - 160.0f)/160.0f;
|
||||
v[2].x = v[1].x = ((x+w) - 160.0f)/160.0f;
|
||||
v[0].y = v[1].y = -(y - 100.0f)/100.0f;
|
||||
v[2].y = v[3].y = -((y+h) - 100.0f)/100.0f;
|
||||
v[0].y = v[1].y = fy;
|
||||
v[2].y = v[3].y = fy - fh;
|
||||
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
v[0].s = v[3].s = (float)((x & flatflag)/dflatsize);
|
||||
v[2].s = v[1].s = (float)(v[0].s + w/dflatsize);
|
||||
v[0].t = v[1].t = (float)((y & flatflag)/dflatsize);
|
||||
v[2].t = v[3].t = (float)(v[0].t + h/dflatsize);
|
||||
// sides
|
||||
v[0].s = v[3].s = (float)(flatflag/dflatsize) * 2;
|
||||
v[2].s = v[1].s = (float)(v[0].s + w/dflatsize) * 2;
|
||||
|
||||
// top/bottom
|
||||
v[0].t = v[1].t = (float)(flatflag/dflatsize) * 2;
|
||||
v[2].t = v[3].t = (float)(v[0].t + h/dflatsize) * 2;
|
||||
|
||||
// needed to texture the poly
|
||||
HWR_GetRawFlat(flatlumpnum);
|
||||
|
||||
//Hurdler: Boris, the same comment as above... but maybe for pics
|
||||
// it not a problem since they don't have any transparent pixel
|
||||
// if I'm right !?
|
||||
// BTW, I see we put 0 for PFs, and If I'm right, that
|
||||
// means we take the previous PFs as default
|
||||
// how can we be sure they are ok?
|
||||
HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Fade down the screen so that the menu drawn on top of it looks brighter
|
||||
// --------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue