mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-28 15:11:55 +00:00
Reduce code duplication
This commit is contained in:
parent
6631f90fa8
commit
869b12c48f
8 changed files with 107 additions and 355 deletions
|
@ -804,57 +804,18 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex)
|
||||||
|
|
||||||
static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
||||||
{
|
{
|
||||||
size_t size, pflatsize;
|
size_t size = W_LumpLength(flatlumpnum);
|
||||||
|
UINT16 pflatsize = R_GetFlatSize(size);
|
||||||
|
|
||||||
// setup the texture info
|
// setup the texture info
|
||||||
grMipmap->format = GL_TEXFMT_P_8;
|
grMipmap->format = GL_TEXFMT_P_8;
|
||||||
grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
|
grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
|
||||||
|
|
||||||
size = W_LumpLength(flatlumpnum);
|
grMipmap->width = pflatsize;
|
||||||
|
grMipmap->height = pflatsize;
|
||||||
switch (size)
|
|
||||||
{
|
|
||||||
case 4194304: // 2048x2048 lump
|
|
||||||
pflatsize = 2048;
|
|
||||||
break;
|
|
||||||
case 1048576: // 1024x1024 lump
|
|
||||||
pflatsize = 1024;
|
|
||||||
break;
|
|
||||||
case 262144:// 512x512 lump
|
|
||||||
pflatsize = 512;
|
|
||||||
break;
|
|
||||||
case 65536: // 256x256 lump
|
|
||||||
pflatsize = 256;
|
|
||||||
break;
|
|
||||||
case 16384: // 128x128 lump
|
|
||||||
pflatsize = 128;
|
|
||||||
break;
|
|
||||||
case 1024: // 32x32 lump
|
|
||||||
pflatsize = 32;
|
|
||||||
break;
|
|
||||||
case 256: // 16x16 lump
|
|
||||||
pflatsize = 16;
|
|
||||||
break;
|
|
||||||
case 64: // 8x8 lump
|
|
||||||
pflatsize = 8;
|
|
||||||
break;
|
|
||||||
case 16: // 4x4 lump
|
|
||||||
pflatsize = 4;
|
|
||||||
break;
|
|
||||||
case 4: // 2x2 lump
|
|
||||||
pflatsize = 2;
|
|
||||||
break;
|
|
||||||
default: // 64x64 lump
|
|
||||||
pflatsize = 64;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
grMipmap->width = (UINT16)pflatsize;
|
|
||||||
grMipmap->height = (UINT16)pflatsize;
|
|
||||||
|
|
||||||
// the flat raw data needn't be converted with palettized textures
|
// the flat raw data needn't be converted with palettized textures
|
||||||
W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum),
|
W_ReadLump(flatlumpnum, Z_Malloc(size, PU_HWRCACHE, &grMipmap->data));
|
||||||
PU_HWRCACHE, &grMipmap->data));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
|
static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
|
||||||
|
|
|
@ -575,58 +575,10 @@ void HWR_DrawPic(INT32 x, INT32 y, lumpnum_t lumpnum)
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
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];
|
FOutVector v[4];
|
||||||
double dflatsize;
|
|
||||||
INT32 flatflag;
|
|
||||||
const size_t len = W_LumpLength(flatlumpnum);
|
const size_t len = W_LumpLength(flatlumpnum);
|
||||||
|
UINT16 flatflag = R_GetFlatSize(len) - 1;
|
||||||
switch (len)
|
double dflatsize = (double)(flatflag + 1);
|
||||||
{
|
|
||||||
case 4194304: // 2048x2048 lump
|
|
||||||
dflatsize = 2048.0f;
|
|
||||||
flatflag = 2047;
|
|
||||||
break;
|
|
||||||
case 1048576: // 1024x1024 lump
|
|
||||||
dflatsize = 1024.0f;
|
|
||||||
flatflag = 1023;
|
|
||||||
break;
|
|
||||||
case 262144:// 512x512 lump
|
|
||||||
dflatsize = 512.0f;
|
|
||||||
flatflag = 511;
|
|
||||||
break;
|
|
||||||
case 65536: // 256x256 lump
|
|
||||||
dflatsize = 256.0f;
|
|
||||||
flatflag = 255;
|
|
||||||
break;
|
|
||||||
case 16384: // 128x128 lump
|
|
||||||
dflatsize = 128.0f;
|
|
||||||
flatflag = 127;
|
|
||||||
break;
|
|
||||||
case 1024: // 32x32 lump
|
|
||||||
dflatsize = 32.0f;
|
|
||||||
flatflag = 31;
|
|
||||||
break;
|
|
||||||
case 256: // 16x16 lump
|
|
||||||
dflatsize = 16.0f;
|
|
||||||
flatflag = 15;
|
|
||||||
break;
|
|
||||||
case 64: // 8x8 lump
|
|
||||||
dflatsize = 8.0f;
|
|
||||||
flatflag = 7;
|
|
||||||
break;
|
|
||||||
case 16: // 4x4 lump
|
|
||||||
dflatsize = 4.0f;
|
|
||||||
flatflag = 3;
|
|
||||||
break;
|
|
||||||
case 4: // 2x2 lump
|
|
||||||
dflatsize = 2.0f;
|
|
||||||
flatflag = 1;
|
|
||||||
break;
|
|
||||||
default: // 64x64 lump
|
|
||||||
dflatsize = 64.0f;
|
|
||||||
flatflag = 63;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3--2
|
// 3--2
|
||||||
// | /|
|
// | /|
|
||||||
|
@ -640,7 +592,6 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
// flat is 64x64 lod and texture offsets are [0.0, 1.0]
|
|
||||||
v[0].s = v[3].s = (float)((x & flatflag)/dflatsize);
|
v[0].s = v[3].s = (float)((x & flatflag)/dflatsize);
|
||||||
v[2].s = v[1].s = (float)(v[0].s + w/dflatsize);
|
v[2].s = v[1].s = (float)(v[0].s + w/dflatsize);
|
||||||
v[0].t = v[1].t = (float)((y & flatflag)/dflatsize);
|
v[0].t = v[1].t = (float)((y & flatflag)/dflatsize);
|
||||||
|
|
|
@ -358,30 +358,39 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, angle_t dir, fixed_t delta)
|
||||||
// -----------------+
|
// -----------------+
|
||||||
static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, levelflat_t *levelflat, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap)
|
static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, levelflat_t *levelflat, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap)
|
||||||
{
|
{
|
||||||
polyvertex_t * pv;
|
FSurfaceInfo Surf;
|
||||||
float height; //constant y for all points on the convex flat polygon
|
FOutVector *v3d;
|
||||||
FOutVector *v3d;
|
polyvertex_t *pv;
|
||||||
INT32 nrPlaneVerts; //verts original define of convex flat polygon
|
|
||||||
INT32 i;
|
|
||||||
float flatxref,flatyref;
|
|
||||||
float fflatwidth = 64.0f, fflatheight = 64.0f;
|
|
||||||
INT32 flatflag = 63;
|
|
||||||
boolean texflat = false;
|
|
||||||
float scrollx = 0.0f, scrolly = 0.0f, anglef = 0.0f;
|
|
||||||
angle_t angle = 0;
|
|
||||||
FSurfaceInfo Surf;
|
|
||||||
float tempxsow, tempytow;
|
|
||||||
pslope_t *slope = NULL;
|
pslope_t *slope = NULL;
|
||||||
|
INT32 shader = SHADER_DEFAULT;
|
||||||
|
|
||||||
|
size_t nrPlaneVerts;
|
||||||
|
INT32 i;
|
||||||
|
|
||||||
|
float height; // constant y for all points on the convex flat polygon
|
||||||
|
float flatxref, flatyref, anglef = 0.0f;
|
||||||
|
float fflatwidth = 64.0f, fflatheight = 64.0f;
|
||||||
|
UINT16 flatflag = 63;
|
||||||
|
|
||||||
|
boolean texflat = false;
|
||||||
|
|
||||||
|
float tempxsow, tempytow;
|
||||||
|
float scrollx = 0.0f, scrolly = 0.0f;
|
||||||
|
angle_t angle = 0;
|
||||||
|
|
||||||
static FOutVector *planeVerts = NULL;
|
static FOutVector *planeVerts = NULL;
|
||||||
static UINT16 numAllocedPlaneVerts = 0;
|
static UINT16 numAllocedPlaneVerts = 0;
|
||||||
|
|
||||||
INT32 shader = SHADER_DEFAULT;
|
|
||||||
|
|
||||||
// no convex poly were generated for this subsector
|
// no convex poly were generated for this subsector
|
||||||
if (!xsub->planepoly)
|
if (!xsub->planepoly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
pv = xsub->planepoly->pts;
|
||||||
|
nrPlaneVerts = xsub->planepoly->numpts;
|
||||||
|
|
||||||
|
if (nrPlaneVerts < 3) // not even a triangle?
|
||||||
|
return;
|
||||||
|
|
||||||
// Get the slope pointer to simplify future code
|
// Get the slope pointer to simplify future code
|
||||||
if (FOFsector)
|
if (FOFsector)
|
||||||
{
|
{
|
||||||
|
@ -404,12 +413,6 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
||||||
|
|
||||||
height = FIXED_TO_FLOAT(fixedheight);
|
height = FIXED_TO_FLOAT(fixedheight);
|
||||||
|
|
||||||
pv = xsub->planepoly->pts;
|
|
||||||
nrPlaneVerts = xsub->planepoly->numpts;
|
|
||||||
|
|
||||||
if (nrPlaneVerts < 3) //not even a triangle ?
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Allocate plane-vertex buffer if we need to
|
// Allocate plane-vertex buffer if we need to
|
||||||
if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts)
|
if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts)
|
||||||
{
|
{
|
||||||
|
@ -424,43 +427,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
||||||
if (levelflat->type == LEVELFLAT_FLAT)
|
if (levelflat->type == LEVELFLAT_FLAT)
|
||||||
{
|
{
|
||||||
size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
|
size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
|
||||||
switch (len)
|
flatflag = R_GetFlatSize(len) - 1;
|
||||||
{
|
fflatwidth = fflatheight = (float)(flatflag + 1);
|
||||||
case 4194304: // 2048x2048 lump
|
|
||||||
fflatwidth = fflatheight = 2048.0f;
|
|
||||||
break;
|
|
||||||
case 1048576: // 1024x1024 lump
|
|
||||||
fflatwidth = fflatheight = 1024.0f;
|
|
||||||
break;
|
|
||||||
case 262144:// 512x512 lump
|
|
||||||
fflatwidth = fflatheight = 512.0f;
|
|
||||||
break;
|
|
||||||
case 65536: // 256x256 lump
|
|
||||||
fflatwidth = fflatheight = 256.0f;
|
|
||||||
break;
|
|
||||||
case 16384: // 128x128 lump
|
|
||||||
fflatwidth = fflatheight = 128.0f;
|
|
||||||
break;
|
|
||||||
case 1024: // 32x32 lump
|
|
||||||
fflatwidth = fflatheight = 32.0f;
|
|
||||||
break;
|
|
||||||
case 256: // 16x16 lump
|
|
||||||
fflatwidth = fflatheight = 16.0f;
|
|
||||||
break;
|
|
||||||
case 64: // 8x8 lump
|
|
||||||
fflatwidth = fflatheight = 8.0f;
|
|
||||||
break;
|
|
||||||
case 16: // 4x4 lump
|
|
||||||
fflatwidth = fflatheight = 4.0f;
|
|
||||||
break;
|
|
||||||
case 4: // 2x2 lump
|
|
||||||
fflatwidth = fflatheight = 2.0f;
|
|
||||||
break;
|
|
||||||
default: // 64x64 lump
|
|
||||||
fflatwidth = fflatheight = 64.0f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
flatflag = ((INT32)fflatwidth)-1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -560,7 +528,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, v3d = planeVerts; i < nrPlaneVerts; i++,v3d++,pv++)
|
for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++)
|
||||||
SETUP3DVERT(v3d, pv->x, pv->y);
|
SETUP3DVERT(v3d, pv->x, pv->y);
|
||||||
|
|
||||||
if (slope)
|
if (slope)
|
||||||
|
@ -2721,13 +2689,13 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
||||||
float height = FIXED_TO_FLOAT(fixedheight); // constant y for all points on the convex flat polygon
|
float height = FIXED_TO_FLOAT(fixedheight); // constant y for all points on the convex flat polygon
|
||||||
float flatxref, flatyref;
|
float flatxref, flatyref;
|
||||||
float fflatwidth = 64.0f, fflatheight = 64.0f;
|
float fflatwidth = 64.0f, fflatheight = 64.0f;
|
||||||
INT32 flatflag = 63;
|
UINT16 flatflag = 63;
|
||||||
|
|
||||||
boolean texflat = false;
|
boolean texflat = false;
|
||||||
|
|
||||||
float scrollx = 0.0f, scrolly = 0.0f;
|
float scrollx = 0.0f, scrolly = 0.0f;
|
||||||
|
float tempxsow, tempytow, anglef = 0.0f;
|
||||||
angle_t angle = 0;
|
angle_t angle = 0;
|
||||||
fixed_t tempxs, tempyt;
|
|
||||||
|
|
||||||
static FOutVector *planeVerts = NULL;
|
static FOutVector *planeVerts = NULL;
|
||||||
static UINT16 numAllocedPlaneVerts = 0;
|
static UINT16 numAllocedPlaneVerts = 0;
|
||||||
|
@ -2754,43 +2722,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
||||||
if (levelflat->type == LEVELFLAT_FLAT)
|
if (levelflat->type == LEVELFLAT_FLAT)
|
||||||
{
|
{
|
||||||
size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
|
size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
|
||||||
switch (len)
|
flatflag = R_GetFlatSize(len) - 1;
|
||||||
{
|
fflatwidth = fflatheight = (float)(flatflag + 1);
|
||||||
case 4194304: // 2048x2048 lump
|
|
||||||
fflatwidth = fflatheight = 2048.0f;
|
|
||||||
break;
|
|
||||||
case 1048576: // 1024x1024 lump
|
|
||||||
fflatwidth = fflatheight = 1024.0f;
|
|
||||||
break;
|
|
||||||
case 262144:// 512x512 lump
|
|
||||||
fflatwidth = fflatheight = 512.0f;
|
|
||||||
break;
|
|
||||||
case 65536: // 256x256 lump
|
|
||||||
fflatwidth = fflatheight = 256.0f;
|
|
||||||
break;
|
|
||||||
case 16384: // 128x128 lump
|
|
||||||
fflatwidth = fflatheight = 128.0f;
|
|
||||||
break;
|
|
||||||
case 1024: // 32x32 lump
|
|
||||||
fflatwidth = fflatheight = 32.0f;
|
|
||||||
break;
|
|
||||||
case 256: // 16x16 lump
|
|
||||||
fflatwidth = fflatheight = 16.0f;
|
|
||||||
break;
|
|
||||||
case 64: // 8x8 lump
|
|
||||||
fflatwidth = fflatheight = 8.0f;
|
|
||||||
break;
|
|
||||||
case 16: // 4x4 lump
|
|
||||||
fflatwidth = fflatheight = 4.0f;
|
|
||||||
break;
|
|
||||||
case 4: // 2x2 lump
|
|
||||||
fflatwidth = fflatheight = 2.0f;
|
|
||||||
break;
|
|
||||||
default: // 64x64 lump
|
|
||||||
fflatwidth = fflatheight = 64.0f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
flatflag = ((INT32)fflatwidth)-1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2853,20 +2786,13 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
||||||
|
|
||||||
if (angle) // Only needs to be done if there's an altered angle
|
if (angle) // Only needs to be done if there's an altered angle
|
||||||
{
|
{
|
||||||
angle = (InvAngle(angle))>>ANGLETOFINESHIFT;
|
tempxsow = flatxref;
|
||||||
|
tempytow = flatyref;
|
||||||
|
|
||||||
// This needs to be done so that it scrolls in a different direction after rotation like software
|
anglef = ANG2RAD(InvAngle(angle));
|
||||||
/*tempxs = FLOAT_TO_FIXED(scrollx);
|
|
||||||
tempyt = FLOAT_TO_FIXED(scrolly);
|
|
||||||
scrollx = (FIXED_TO_FLOAT(FixedMul(tempxs, FINECOSINE(angle)) - FixedMul(tempyt, FINESINE(angle))));
|
|
||||||
scrolly = (FIXED_TO_FLOAT(FixedMul(tempxs, FINESINE(angle)) + FixedMul(tempyt, FINECOSINE(angle))));*/
|
|
||||||
|
|
||||||
// This needs to be done so everything aligns after rotation
|
flatxref = (tempxsow * cos(anglef)) - (tempytow * sin(anglef));
|
||||||
// It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does
|
flatyref = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));
|
||||||
tempxs = FLOAT_TO_FIXED(flatxref);
|
|
||||||
tempyt = FLOAT_TO_FIXED(flatyref);
|
|
||||||
flatxref = (FIXED_TO_FLOAT(FixedMul(tempxs, FINECOSINE(angle)) - FixedMul(tempyt, FINESINE(angle))));
|
|
||||||
flatyref = (FIXED_TO_FLOAT(FixedMul(tempxs, FINESINE(angle)) + FixedMul(tempyt, FINECOSINE(angle))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++)
|
for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++)
|
||||||
|
@ -2887,10 +2813,11 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
||||||
// Need to rotate before translate
|
// Need to rotate before translate
|
||||||
if (angle) // Only needs to be done if there's an altered angle
|
if (angle) // Only needs to be done if there's an altered angle
|
||||||
{
|
{
|
||||||
tempxs = FLOAT_TO_FIXED(v3d->s);
|
tempxsow = v3d->s;
|
||||||
tempyt = FLOAT_TO_FIXED(v3d->t);
|
tempytow = v3d->t;
|
||||||
v3d->s = (FIXED_TO_FLOAT(FixedMul(tempxs, FINECOSINE(angle)) - FixedMul(tempyt, FINESINE(angle))));
|
|
||||||
v3d->t = (FIXED_TO_FLOAT(FixedMul(tempxs, FINESINE(angle)) + FixedMul(tempyt, FINECOSINE(angle))));
|
v3d->s = (tempxsow * cos(anglef)) - (tempytow * sin(anglef));
|
||||||
|
v3d->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));
|
||||||
}
|
}
|
||||||
|
|
||||||
v3d->x = FIXED_TO_FLOAT(polysector->vertices[i]->x);
|
v3d->x = FIXED_TO_FLOAT(polysector->vertices[i]->x);
|
||||||
|
|
|
@ -870,7 +870,6 @@ void R_DrawSinglePlane(visplane_t *pl)
|
||||||
INT32 x;
|
INT32 x;
|
||||||
INT32 stop, angle;
|
INT32 stop, angle;
|
||||||
ffloor_t *rover;
|
ffloor_t *rover;
|
||||||
INT32 type;
|
|
||||||
INT32 spanfunctype = BASEDRAWFUNC;
|
INT32 spanfunctype = BASEDRAWFUNC;
|
||||||
|
|
||||||
if (!(pl->minx <= pl->maxx))
|
if (!(pl->minx <= pl->maxx))
|
||||||
|
@ -883,8 +882,8 @@ void R_DrawSinglePlane(visplane_t *pl)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
levelflat = &levelflats[pl->picnum];
|
||||||
planeripple.active = false;
|
planeripple.active = false;
|
||||||
spanfunc = spanfuncs[BASEDRAWFUNC];
|
|
||||||
|
|
||||||
if (pl->polyobj)
|
if (pl->polyobj)
|
||||||
{
|
{
|
||||||
|
@ -995,29 +994,25 @@ void R_DrawSinglePlane(visplane_t *pl)
|
||||||
light = (pl->lightlevel >> LIGHTSEGSHIFT);
|
light = (pl->lightlevel >> LIGHTSEGSHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentplane = pl;
|
|
||||||
ds_powersoftwo = false;
|
ds_powersoftwo = false;
|
||||||
levelflat = &levelflats[pl->picnum];
|
|
||||||
|
|
||||||
/* :james: */
|
/* :james: */
|
||||||
type = levelflat->type;
|
switch (levelflat->type)
|
||||||
switch (type)
|
|
||||||
{
|
{
|
||||||
case LEVELFLAT_NONE:
|
case LEVELFLAT_NONE:
|
||||||
return;
|
return;
|
||||||
case LEVELFLAT_FLAT:
|
case LEVELFLAT_FLAT:
|
||||||
ds_source = (UINT8 *)R_GetFlat(levelflat->u.flat.lumpnum);
|
ds_source = (UINT8 *)R_GetFlat(levelflat->u.flat.lumpnum);
|
||||||
R_CheckFlatLength(W_LumpLength(levelflat->u.flat.lumpnum));
|
R_SetFlatVars(W_LumpLength(levelflat->u.flat.lumpnum));
|
||||||
ds_powersoftwo = true; // Raw flats always have dimensions that are powers-of-two numbers.
|
ds_powersoftwo = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ds_source = (UINT8 *)R_GetLevelFlat(levelflat);
|
ds_source = (UINT8 *)R_GetLevelFlat(levelflat);
|
||||||
if (!ds_source)
|
if (!ds_source)
|
||||||
return;
|
return;
|
||||||
// Check if this texture or patch has power-of-two dimensions.
|
else if (R_CheckPowersOfTwo())
|
||||||
if (R_CheckPowersOfTwo())
|
|
||||||
{
|
{
|
||||||
R_CheckFlatLength(ds_flatwidth * ds_flatheight);
|
R_SetFlatVars(ds_flatwidth * ds_flatheight);
|
||||||
ds_powersoftwo = true;
|
ds_powersoftwo = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1091,7 +1086,7 @@ void R_DrawSinglePlane(visplane_t *pl)
|
||||||
planezlight = zlight[light];
|
planezlight = zlight[light];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the correct span drawer depending on the powers-of-twoness
|
// Set the span drawer
|
||||||
if (!ds_powersoftwo)
|
if (!ds_powersoftwo)
|
||||||
{
|
{
|
||||||
if (spanfuncs_npo2[spanfunctype])
|
if (spanfuncs_npo2[spanfunctype])
|
||||||
|
@ -1108,6 +1103,7 @@ void R_DrawSinglePlane(visplane_t *pl)
|
||||||
pl->bottom[pl->maxx+1] = 0x0000;
|
pl->bottom[pl->maxx+1] = 0x0000;
|
||||||
pl->bottom[pl->minx-1] = 0x0000;
|
pl->bottom[pl->minx-1] = 0x0000;
|
||||||
|
|
||||||
|
currentplane = pl;
|
||||||
stop = pl->maxx + 1;
|
stop = pl->maxx + 1;
|
||||||
|
|
||||||
if (pl->slope)
|
if (pl->slope)
|
||||||
|
|
|
@ -416,7 +416,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
|
||||||
|
|
||||||
if (R_CheckPowersOfTwo())
|
if (R_CheckPowersOfTwo())
|
||||||
{
|
{
|
||||||
R_CheckFlatLength(ds_flatwidth * ds_flatheight);
|
R_SetFlatVars(ds_flatwidth * ds_flatheight);
|
||||||
ds_powersoftwo = true;
|
ds_powersoftwo = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
124
src/r_textures.c
124
src/r_textures.c
|
@ -619,9 +619,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_CheckPowersOfTwo
|
// Checks if the current flat's dimensions are powers of two
|
||||||
//
|
|
||||||
// Checks if the flat's dimensions are powers of two.
|
|
||||||
//
|
//
|
||||||
boolean R_CheckPowersOfTwo(void)
|
boolean R_CheckPowersOfTwo(void)
|
||||||
{
|
{
|
||||||
|
@ -637,67 +635,67 @@ boolean R_CheckPowersOfTwo(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_CheckFlatLength
|
// Returns the flat size corresponding to the length of a lump
|
||||||
//
|
//
|
||||||
// Determine the flat's dimensions from its lump length.
|
UINT16 R_GetFlatSize(size_t length)
|
||||||
//
|
|
||||||
void R_CheckFlatLength(size_t length)
|
|
||||||
{
|
{
|
||||||
INT32 size, bits;
|
|
||||||
|
|
||||||
switch (length)
|
switch (length)
|
||||||
{
|
{
|
||||||
case 4194304: // 2048x2048 lump
|
case 4194304: // 2048x2048 lump
|
||||||
size = 2048;
|
return 2048;
|
||||||
bits = 11;
|
|
||||||
break;
|
|
||||||
case 1048576: // 1024x1024 lump
|
case 1048576: // 1024x1024 lump
|
||||||
size = 1024;
|
return 1024;
|
||||||
bits = 10;
|
|
||||||
break;
|
|
||||||
case 262144:// 512x512 lump
|
case 262144:// 512x512 lump
|
||||||
size = 512;
|
return 512;
|
||||||
bits = 9;
|
|
||||||
break;
|
|
||||||
case 65536: // 256x256 lump
|
case 65536: // 256x256 lump
|
||||||
size = 256;
|
return 256;
|
||||||
bits = 8;
|
|
||||||
break;
|
|
||||||
case 16384: // 128x128 lump
|
case 16384: // 128x128 lump
|
||||||
size = 128;
|
return 128;
|
||||||
bits = 7;
|
|
||||||
break;
|
|
||||||
case 1024: // 32x32 lump
|
case 1024: // 32x32 lump
|
||||||
size = 32;
|
return 32;
|
||||||
bits = 5;
|
|
||||||
break;
|
|
||||||
case 256: // 16x16 lump
|
case 256: // 16x16 lump
|
||||||
size = 16;
|
return 16;
|
||||||
bits = 4;
|
|
||||||
break;
|
|
||||||
case 64: // 8x8 lump
|
case 64: // 8x8 lump
|
||||||
size = 8;
|
return 8;
|
||||||
bits = 3;
|
|
||||||
break;
|
|
||||||
case 16: // 4x4 lump
|
case 16: // 4x4 lump
|
||||||
size = 4;
|
return 4;
|
||||||
bits = 2;
|
|
||||||
break;
|
|
||||||
case 4: // 2x2 lump
|
case 4: // 2x2 lump
|
||||||
size = 2;
|
return 2;
|
||||||
bits = 1;
|
|
||||||
break;
|
|
||||||
default: // 64x64 lump
|
default: // 64x64 lump
|
||||||
size = 64;
|
return 64;
|
||||||
bits = 6;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determines a flat's width bits from its size
|
||||||
|
//
|
||||||
|
UINT8 R_GetFlatBits(INT32 size)
|
||||||
|
{
|
||||||
|
switch (size)
|
||||||
|
{
|
||||||
|
case 2048: return 11;
|
||||||
|
case 1024: return 10;
|
||||||
|
case 512: return 9;
|
||||||
|
case 256: return 8;
|
||||||
|
case 128: return 7;
|
||||||
|
case 32: return 5;
|
||||||
|
case 16: return 4;
|
||||||
|
case 8: return 3;
|
||||||
|
case 4: return 2;
|
||||||
|
case 2: return 1;
|
||||||
|
default: return 6; // 64x64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void R_SetFlatVars(size_t length)
|
||||||
|
{
|
||||||
|
UINT16 size = R_GetFlatSize(length);
|
||||||
|
UINT8 bits = R_GetFlatBits(size);
|
||||||
|
|
||||||
nflatshiftup = 16 - bits;
|
nflatshiftup = 16 - bits;
|
||||||
nflatxshift = 16 + nflatshiftup;
|
nflatxshift = 16 + nflatshiftup;
|
||||||
nflatyshift = nflatxshift - bits;
|
nflatyshift = nflatxshift - bits;
|
||||||
nflatmask = (size - 1) * size;
|
nflatmask = (size - 1) * size;
|
||||||
ds_flatwidth = ds_flatheight = size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -746,7 +744,7 @@ Rloadflats (INT32 i, INT32 w)
|
||||||
UINT16 wadnum = (UINT16)w;
|
UINT16 wadnum = (UINT16)w;
|
||||||
lumpnum_t lumpnum = texstart + j;
|
lumpnum_t lumpnum = texstart + j;
|
||||||
size_t lumplength;
|
size_t lumplength;
|
||||||
size_t flatsize = 0;
|
size_t flatsize;
|
||||||
|
|
||||||
if (wadfiles[w]->type == RET_PK3)
|
if (wadfiles[w]->type == RET_PK3)
|
||||||
{
|
{
|
||||||
|
@ -756,43 +754,7 @@ Rloadflats (INT32 i, INT32 w)
|
||||||
|
|
||||||
flatlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
|
flatlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
|
||||||
lumplength = W_LumpLengthPwad(wadnum, lumpnum);
|
lumplength = W_LumpLengthPwad(wadnum, lumpnum);
|
||||||
|
flatsize = R_GetFlatSize(lumplength);
|
||||||
switch (lumplength)
|
|
||||||
{
|
|
||||||
case 4194304: // 2048x2048 lump
|
|
||||||
flatsize = 2048;
|
|
||||||
break;
|
|
||||||
case 1048576: // 1024x1024 lump
|
|
||||||
flatsize = 1024;
|
|
||||||
break;
|
|
||||||
case 262144:// 512x512 lump
|
|
||||||
flatsize = 512;
|
|
||||||
break;
|
|
||||||
case 65536: // 256x256 lump
|
|
||||||
flatsize = 256;
|
|
||||||
break;
|
|
||||||
case 16384: // 128x128 lump
|
|
||||||
flatsize = 128;
|
|
||||||
break;
|
|
||||||
case 1024: // 32x32 lump
|
|
||||||
flatsize = 32;
|
|
||||||
break;
|
|
||||||
case 256: // 16x16 lump
|
|
||||||
flatsize = 16;
|
|
||||||
break;
|
|
||||||
case 64: // 8x8 lump
|
|
||||||
flatsize = 8;
|
|
||||||
break;
|
|
||||||
case 16: // 4x4 lump
|
|
||||||
flatsize = 4;
|
|
||||||
break;
|
|
||||||
case 4: // 2x2 lump
|
|
||||||
flatsize = 2;
|
|
||||||
break;
|
|
||||||
default: // 64x64 lump
|
|
||||||
flatsize = 64;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//CONS_Printf("\n\"%s\" is a flat, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),flatsize,flatsize);
|
//CONS_Printf("\n\"%s\" is a flat, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),flatsize,flatsize);
|
||||||
texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL);
|
texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL);
|
||||||
|
|
|
@ -91,7 +91,9 @@ UINT8 *R_GetColumn(fixed_t tex, INT32 col);
|
||||||
void *R_GetFlat(lumpnum_t flatnum);
|
void *R_GetFlat(lumpnum_t flatnum);
|
||||||
|
|
||||||
boolean R_CheckPowersOfTwo(void);
|
boolean R_CheckPowersOfTwo(void);
|
||||||
void R_CheckFlatLength(size_t length);
|
UINT16 R_GetFlatSize(size_t length);
|
||||||
|
UINT8 R_GetFlatBits(INT32 size);
|
||||||
|
void R_SetFlatVars(size_t length);
|
||||||
|
|
||||||
// Returns the texture number for the texture name.
|
// Returns the texture number for the texture name.
|
||||||
INT32 R_TextureNumForName(const char *name);
|
INT32 R_TextureNumForName(const char *name);
|
||||||
|
|
|
@ -1705,7 +1705,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum)
|
||||||
fixed_t dx, dy, xfrac, yfrac;
|
fixed_t dx, dy, xfrac, yfrac;
|
||||||
const UINT8 *src, *deststop;
|
const UINT8 *src, *deststop;
|
||||||
UINT8 *flat, *dest;
|
UINT8 *flat, *dest;
|
||||||
size_t size, lflatsize, flatshift;
|
size_t lflatsize, flatshift;
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
|
@ -1715,55 +1715,8 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size = W_LumpLength(flatnum);
|
lflatsize = R_GetFlatSize(W_LumpLength(flatnum));
|
||||||
|
flatshift = R_GetFlatBits(lflatsize);
|
||||||
switch (size)
|
|
||||||
{
|
|
||||||
case 4194304: // 2048x2048 lump
|
|
||||||
lflatsize = 2048;
|
|
||||||
flatshift = 11;
|
|
||||||
break;
|
|
||||||
case 1048576: // 1024x1024 lump
|
|
||||||
lflatsize = 1024;
|
|
||||||
flatshift = 10;
|
|
||||||
break;
|
|
||||||
case 262144:// 512x512 lump
|
|
||||||
lflatsize = 512;
|
|
||||||
flatshift = 9;
|
|
||||||
break;
|
|
||||||
case 65536: // 256x256 lump
|
|
||||||
lflatsize = 256;
|
|
||||||
flatshift = 8;
|
|
||||||
break;
|
|
||||||
case 16384: // 128x128 lump
|
|
||||||
lflatsize = 128;
|
|
||||||
flatshift = 7;
|
|
||||||
break;
|
|
||||||
case 1024: // 32x32 lump
|
|
||||||
lflatsize = 32;
|
|
||||||
flatshift = 5;
|
|
||||||
break;
|
|
||||||
case 256: // 16x16 lump
|
|
||||||
lflatsize = 16;
|
|
||||||
flatshift = 4;
|
|
||||||
break;
|
|
||||||
case 64: // 8x8 lump
|
|
||||||
lflatsize = 8;
|
|
||||||
flatshift = 3;
|
|
||||||
break;
|
|
||||||
case 16: // 4x4 lump
|
|
||||||
lflatsize = 4;
|
|
||||||
flatshift = 2;
|
|
||||||
break;
|
|
||||||
case 4: // 2x2 lump
|
|
||||||
lflatsize = 2;
|
|
||||||
flatshift = 1;
|
|
||||||
break;
|
|
||||||
default: // 64x64 lump
|
|
||||||
lflatsize = 64;
|
|
||||||
flatshift = 6;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
flat = W_CacheLumpNum(flatnum, PU_CACHE);
|
flat = W_CacheLumpNum(flatnum, PU_CACHE);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue