make hwrender compile

This commit is contained in:
Jaime Passos 2019-11-08 22:58:41 -03:00
parent e15ffd2bc8
commit 809f79c951
4 changed files with 150 additions and 205 deletions

View File

@ -922,29 +922,6 @@ GLTexture_t *HWR_GetTexture(INT32 tex)
return grtex; return grtex;
} }
// HWR_RenderPlane and HWR_RenderPolyObjectPlane need this to get the flat dimensions from a patch.
lumpnum_t gr_patchflat;
static void HWR_LoadPatchFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
{
UINT8 *flat;
patch_t *patch = (patch_t *)W_CacheLumpNum(flatlumpnum, PU_STATIC);
size_t lumplength = W_LumpLength(flatlumpnum);
#ifndef NO_PNG_LUMPS
if (R_IsLumpPNG((UINT8 *)patch, lumplength))
patch = R_PNGToPatch((UINT8 *)patch, lumplength, NULL, false);
#endif
grMipmap->width = (UINT16)SHORT(patch->width);
grMipmap->height = (UINT16)SHORT(patch->height);
flat = Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->grInfo.data);
memset(flat, TRANSPARENTPIXEL, grMipmap->width * grMipmap->height);
R_PatchToFlat(patch, flat);
}
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, pflatsize;
@ -985,40 +962,15 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
break; break;
} }
if (R_CheckIfPatch(flatlumpnum)) grMipmap->width = (UINT16)pflatsize;
HWR_LoadPatchFlat(grMipmap, flatlumpnum); grMipmap->height = (UINT16)pflatsize;
else
{
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(W_LumpLength(flatlumpnum),
PU_HWRCACHE, &grMipmap->grInfo.data)); PU_HWRCACHE, &grMipmap->grInfo.data));
}
} }
// Download a Doom 'flat' to the hardware cache and make it ready for use static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
void HWR_GetFlat(lumpnum_t flatlumpnum)
{
GLMipmap_t *grmip;
grmip = &HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
if (!grmip->downloaded && !grmip->grInfo.data)
HWR_CacheFlat(grmip, flatlumpnum);
HWD.pfnSetTexture(grmip);
// The system-memory data can be purged now.
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED);
gr_patchflat = 0;
if (R_CheckIfPatch(flatlumpnum))
gr_patchflat = flatlumpnum;
}
static void HWR_LoadTextureFlat(GLMipmap_t *grMipmap, INT32 texturenum)
{ {
UINT8 *flat; UINT8 *flat;
@ -1040,24 +992,44 @@ static void HWR_LoadTextureFlat(GLMipmap_t *grMipmap, INT32 texturenum)
R_TextureToFlat(texturenum, flat); R_TextureToFlat(texturenum, flat);
} }
void HWR_GetTextureFlat(INT32 texturenum) // Download a Doom 'flat' to the hardware cache and make it ready for use
void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum)
{ {
GLTexture_t *grtex; GLMipmap_t *grmip = &HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
#ifdef PARANOIA
if ((unsigned)texturenum >= gr_numtextures)
I_Error("HWR_GetTextureFlat: texturenum >= numtextures\n");
#endif
if (texturenum == 0 || texturenum == -1)
return;
grtex = &gr_textures2[texturenum];
if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded) if (!grmip->downloaded && !grmip->grInfo.data)
HWR_LoadTextureFlat(&grtex->mipmap, texturenum); HWR_CacheFlat(grmip, flatlumpnum);
HWD.pfnSetTexture(&grtex->mipmap); HWD.pfnSetTexture(grmip);
// The system-memory data can be purged now. // The system-memory data can be purged now.
Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED);
}
void HWR_GetFlat(levelflat_t *levelflat)
{
if (levelflat->type == LEVELFLAT_FLAT)
HWR_LiterallyGetFlat(levelflat->u.flat.lumpnum);
else if (levelflat->type == LEVELFLAT_TEXTURE)
{
GLTexture_t *grtex;
INT32 texturenum = levelflat->u.texture.num;
#ifdef PARANOIA
if ((unsigned)texturenum >= gr_numtextures)
I_Error("HWR_GetFlat: texturenum >= numtextures\n");
#endif
if (texturenum == 0 || texturenum == -1)
return;
grtex = &gr_textures2[texturenum];
if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded)
HWR_CacheTextureAsFlat(&grtex->mipmap, texturenum);
HWD.pfnSetTexture(&grtex->mipmap);
// The system-memory data can be purged now.
Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED);
}
} }
// //

View File

@ -647,7 +647,7 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum
v[0].tow = v[1].tow = (float)((y & flatflag)/dflatsize); v[0].tow = v[1].tow = (float)((y & flatflag)/dflatsize);
v[2].tow = v[3].tow = (float)(v[0].tow + h/dflatsize); v[2].tow = v[3].tow = (float)(v[0].tow + h/dflatsize);
HWR_GetFlat(flatlumpnum); HWR_LiterallyGetFlat(flatlumpnum);
//Hurdler: Boris, the same comment as above... but maybe for pics //Hurdler: Boris, the same comment as above... but maybe for pics
// it not a problem since they don't have any transparent pixel // it not a problem since they don't have any transparent pixel

View File

@ -23,6 +23,7 @@
#include "hw_defs.h" #include "hw_defs.h"
#include "hw_main.h" #include "hw_main.h"
#include "../m_misc.h" #include "../m_misc.h"
#include "../p_setup.h"
// the original aspect ratio of Doom graphics isn't square // the original aspect ratio of Doom graphics isn't square
#define ORIGINAL_ASPECT (320.0f/200.0f) #define ORIGINAL_ASPECT (320.0f/200.0f)
@ -100,8 +101,8 @@ void HWR_InitTextureCache(void);
void HWR_FreeTextureCache(void); void HWR_FreeTextureCache(void);
void HWR_FreeExtraSubsectors(void); void HWR_FreeExtraSubsectors(void);
void HWR_GetFlat(lumpnum_t flatlumpnum); void HWR_GetFlat(levelflat_t *levelflat);
void HWR_GetTextureFlat(INT32 texturenum); void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum);
GLTexture_t *HWR_GetTexture(INT32 tex); GLTexture_t *HWR_GetTexture(INT32 tex);
void HWR_GetPatch(GLPatch_t *gpatch); void HWR_GetPatch(GLPatch_t *gpatch);
void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap); void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap);
@ -115,8 +116,6 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
// -------- // --------
// hw_draw.c // hw_draw.c
// -------- // --------
extern lumpnum_t gr_patchflat;
extern float gr_patch_scalex; extern float gr_patch_scalex;
extern float gr_patch_scaley; extern float gr_patch_scaley;

View File

@ -70,9 +70,9 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing);
#endif #endif
#ifdef SORTING #ifdef SORTING
void HWR_AddTransparentFloor(lumpnum_t lumpnum, INT32 texturenum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight,
INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap); INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, INT32 texturenum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, void HWR_AddTransparentPolyobjectFloor(levelflat_t *levelflat, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight,
INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap); INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap);
#else #else
static void HWR_Add3DWater(lumpnum_t lumpnum, extrasubsector_t *xsub, fixed_t fixedheight, static void HWR_Add3DWater(lumpnum_t lumpnum, extrasubsector_t *xsub, fixed_t fixedheight,
@ -522,7 +522,7 @@ static UINT8 HWR_FogBlockAlpha(INT32 light, UINT32 color) // Let's see if this c
// HWR_RenderPlane : Render a floor or ceiling convex polygon // HWR_RenderPlane : Render a floor or ceiling convex polygon
// -----------------+ // -----------------+
static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight,
FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, INT32 texturenum, sector_t *FOFsector, UINT8 alpha, boolean fogplane, extracolormap_t *planecolormap) FBITFIELD PolyFlags, INT32 lightlevel, levelflat_t *levelflat, sector_t *FOFsector, UINT8 alpha, boolean fogplane, extracolormap_t *planecolormap)
{ {
polyvertex_t * pv; polyvertex_t * pv;
float height; //constant y for all points on the convex flat polygon float height; //constant y for all points on the convex flat polygon
@ -531,8 +531,8 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
INT32 i; INT32 i;
float flatxref,flatyref; float flatxref,flatyref;
float fflatwidth, fflatheight; float fflatwidth, fflatheight;
INT32 flatflag; INT32 flatflag = 0;
boolean texflat = true; boolean texflat = false;
size_t len; size_t len;
float scrollx = 0.0f, scrolly = 0.0f; float scrollx = 0.0f, scrolly = 0.0f;
angle_t angle = 0; angle_t angle = 0;
@ -541,7 +541,6 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
#ifdef ESLOPE #ifdef ESLOPE
pslope_t *slope = NULL; pslope_t *slope = NULL;
#endif #endif
patch_t *patch;
static FOutVector *planeVerts = NULL; static FOutVector *planeVerts = NULL;
static UINT16 numAllocedPlaneVerts = 0; static UINT16 numAllocedPlaneVerts = 0;
@ -597,48 +596,45 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts); Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts);
} }
len = W_LumpLength(lumpnum); if (levelflat->type == LEVELFLAT_TEXTURE)
switch (len)
{ {
case 4194304: // 2048x2048 lump fflatwidth = textures[levelflat->u.texture.num]->width;
fflatwidth = fflatheight = 2048.0f; fflatheight = textures[levelflat->u.texture.num]->height;
break; texflat = true;
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;
default: // 64x64 lump
fflatwidth = fflatheight = 64.0f;
break;
} }
else if (levelflat->type == LEVELFLAT_TEXTURE)
flatflag = ((INT32)fflatwidth)-1;
if (texturenum != 0 && texturenum != -1)
{ {
fflatwidth = textures[texturenum]->width; len = W_LumpLength(levelflat->u.flat.lumpnum);
fflatheight = textures[texturenum]->height;
switch (len)
{
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;
default: // 64x64 lump
fflatwidth = fflatheight = 64.0f;
break;
}
flatflag = ((INT32)fflatwidth)-1;
} }
else if (gr_patchflat && R_CheckIfPatch(gr_patchflat)) // Just in case? else // LEVELFLAT_NONE
{ return;
patch = (patch_t *)W_CacheLumpNum(gr_patchflat, PU_STATIC);
fflatwidth = SHORT(patch->width);
fflatheight = SHORT(patch->height);
}
else
texflat = false;
// reference point for flat texture coord for each vertex around the polygon // reference point for flat texture coord for each vertex around the polygon
flatxref = (float)(((fixed_t)pv->x & (~flatflag)) / fflatwidth); flatxref = (float)(((fixed_t)pv->x & (~flatflag)) / fflatwidth);
@ -3183,7 +3179,7 @@ static inline void HWR_AddPolyObjectSegs(void)
#ifdef POLYOBJECTS_PLANES #ifdef POLYOBJECTS_PLANES
static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight,
FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, INT32 texturenum, sector_t *FOFsector, FBITFIELD blendmode, UINT8 lightlevel, levelflat_t *levelflat, sector_t *FOFsector,
UINT8 alpha, extracolormap_t *planecolormap) UINT8 alpha, extracolormap_t *planecolormap)
{ {
float height; //constant y for all points on the convex flat polygon float height; //constant y for all points on the convex flat polygon
@ -3191,15 +3187,14 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
INT32 i; INT32 i;
float flatxref,flatyref; float flatxref,flatyref;
float fflatwidth, fflatheight; float fflatwidth, fflatheight;
INT32 flatflag; INT32 flatflag = 0;
boolean texflat = true; boolean texflat = false;
size_t len; size_t len;
float scrollx = 0.0f, scrolly = 0.0f; float scrollx = 0.0f, scrolly = 0.0f;
angle_t angle = 0; angle_t angle = 0;
FSurfaceInfo Surf; FSurfaceInfo Surf;
fixed_t tempxsow, tempytow; fixed_t tempxsow, tempytow;
size_t nrPlaneVerts; size_t nrPlaneVerts;
patch_t *patch;
static FOutVector *planeVerts = NULL; static FOutVector *planeVerts = NULL;
static UINT16 numAllocedPlaneVerts = 0; static UINT16 numAllocedPlaneVerts = 0;
@ -3225,48 +3220,45 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts); Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts);
} }
len = W_LumpLength(lumpnum); if (levelflat->type == LEVELFLAT_TEXTURE)
switch (len)
{ {
case 4194304: // 2048x2048 lump fflatwidth = textures[levelflat->u.texture.num]->width;
fflatwidth = fflatheight = 2048.0f; fflatheight = textures[levelflat->u.texture.num]->height;
break; texflat = true;
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;
default: // 64x64 lump
fflatwidth = fflatheight = 64.0f;
break;
} }
else if (levelflat->type == LEVELFLAT_TEXTURE)
flatflag = ((INT32)fflatwidth)-1;
if (texturenum != 0 && texturenum != -1)
{ {
fflatwidth = textures[texturenum]->width; len = W_LumpLength(levelflat->u.flat.lumpnum);
fflatheight = textures[texturenum]->height;
switch (len)
{
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;
default: // 64x64 lump
fflatwidth = fflatheight = 64.0f;
break;
}
flatflag = ((INT32)fflatwidth)-1;
} }
else if (gr_patchflat && R_CheckIfPatch(gr_patchflat)) // Just in case? else // LEVELFLAT_NONE
{ return;
patch = (patch_t *)W_CacheLumpNum(gr_patchflat, PU_STATIC);
fflatwidth = SHORT(patch->width);
fflatheight = SHORT(patch->height);
}
else
texflat = false;
// reference point for flat texture coord for each vertex around the polygon // reference point for flat texture coord for each vertex around the polygon
flatxref = (float)((polysector->origVerts[0].x & (~flatflag)) / fflatwidth); flatxref = (float)((polysector->origVerts[0].x & (~flatflag)) / fflatwidth);
@ -3400,15 +3392,14 @@ static void HWR_AddPolyObjectPlanes(void)
FBITFIELD blendmode; FBITFIELD blendmode;
memset(&Surf, 0x00, sizeof(Surf)); memset(&Surf, 0x00, sizeof(Surf));
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, levelflats[polyobjsector->floorpic].texturenum, po_ptrs[i], false, polyobjsector->floorheight, HWR_AddTransparentPolyobjectFloor(&levelflats[polyobjsector->floorpic], po_ptrs[i], false, polyobjsector->floorheight,
(light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), Surf.FlatColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap)); (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), Surf.FlatColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap));
} }
else else
{ {
HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum); HWR_GetFlat(&levelflats[polyobjsector->floorpic]);
HWR_GetTextureFlat(levelflats[polyobjsector->floorpic].texturenum);
HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude, HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude,
(light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), levelflats[polyobjsector->floorpic].lumpnum, levelflats[polyobjsector->floorpic].texturenum, (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), &levelflats[polyobjsector->floorpic],
polyobjsector, 255, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap)); polyobjsector, 255, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap));
} }
} }
@ -3424,15 +3415,14 @@ static void HWR_AddPolyObjectPlanes(void)
FBITFIELD blendmode; FBITFIELD blendmode;
memset(&Surf, 0x00, sizeof(Surf)); memset(&Surf, 0x00, sizeof(Surf));
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, levelflats[polyobjsector->floorpic].texturenum, po_ptrs[i], true, polyobjsector->ceilingheight, HWR_AddTransparentPolyobjectFloor(&levelflats[polyobjsector->ceilingpic], po_ptrs[i], true, polyobjsector->ceilingheight,
(light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), Surf.FlatColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap)); (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), Surf.FlatColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap));
} }
else else
{ {
HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum); HWR_GetFlat(&levelflats[polyobjsector->ceilingpic]);
HWR_GetTextureFlat(levelflats[polyobjsector->ceilingpic].texturenum);
HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude, HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude,
(light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), levelflats[polyobjsector->floorpic].lumpnum, levelflats[polyobjsector->floorpic].texturenum, (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), &levelflats[polyobjsector->floorpic],
polyobjsector, 255, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap)); polyobjsector, 255, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap));
} }
} }
@ -3583,13 +3573,12 @@ static void HWR_Subsector(size_t num)
{ {
if (sub->validcount != validcount) if (sub->validcount != validcount)
{ {
HWR_GetFlat(levelflats[gr_frontsector->floorpic].lumpnum); HWR_GetFlat(&levelflats[gr_frontsector->floorpic]);
HWR_GetTextureFlat(levelflats[gr_frontsector->floorpic].texturenum);
HWR_RenderPlane(gr_frontsector, &extrasubsectors[num], false, HWR_RenderPlane(gr_frontsector, &extrasubsectors[num], false,
// Hack to make things continue to work around slopes. // Hack to make things continue to work around slopes.
locFloorHeight == cullFloorHeight ? locFloorHeight : gr_frontsector->floorheight, locFloorHeight == cullFloorHeight ? locFloorHeight : gr_frontsector->floorheight,
// We now return you to your regularly scheduled rendering. // We now return you to your regularly scheduled rendering.
PF_Occlude, floorlightlevel, levelflats[gr_frontsector->floorpic].lumpnum, levelflats[gr_frontsector->floorpic].texturenum, NULL, 255, false, floorcolormap); PF_Occlude, floorlightlevel, &levelflats[gr_frontsector->floorpic], NULL, 255, false, floorcolormap);
} }
} }
else else
@ -3606,13 +3595,12 @@ static void HWR_Subsector(size_t num)
{ {
if (sub->validcount != validcount) if (sub->validcount != validcount)
{ {
HWR_GetFlat(levelflats[gr_frontsector->ceilingpic].lumpnum); HWR_GetFlat(&levelflats[gr_frontsector->ceilingpic]);
HWR_GetTextureFlat(levelflats[gr_frontsector->ceilingpic].texturenum);
HWR_RenderPlane(NULL, &extrasubsectors[num], true, HWR_RenderPlane(NULL, &extrasubsectors[num], true,
// Hack to make things continue to work around slopes. // Hack to make things continue to work around slopes.
locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gr_frontsector->ceilingheight, locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gr_frontsector->ceilingheight,
// We now return you to your regularly scheduled rendering. // We now return you to your regularly scheduled rendering.
PF_Occlude, ceilinglightlevel, levelflats[gr_frontsector->ceilingpic].lumpnum, levelflats[gr_frontsector->ceilingpic].texturenum, NULL, 255, false, ceilingcolormap); PF_Occlude, ceilinglightlevel, &levelflats[gr_frontsector->ceilingpic], NULL, 255, false, ceilingcolormap);
} }
} }
else else
@ -3671,7 +3659,7 @@ static void HWR_Subsector(size_t num)
else else
alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, NORMALFOG); alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, NORMALFOG);
HWR_AddTransparentFloor(0, 0, HWR_AddTransparentFloor(NULL,
&extrasubsectors[num], &extrasubsectors[num],
false, false,
*rover->bottomheight, *rover->bottomheight,
@ -3689,8 +3677,7 @@ static void HWR_Subsector(size_t num)
*gr_frontsector->lightlist[light].lightlevel, *gr_frontsector->lightlist[light].lightlevel,
rover->alpha-1, rover->master->frontsector); rover->alpha-1, rover->master->frontsector);
#else #else
HWR_AddTransparentFloor(levelflats[*rover->bottompic].lumpnum, HWR_AddTransparentFloor(&levelflats[*rover->bottompic],
levelflats[*rover->bottompic].texturenum,
&extrasubsectors[num], &extrasubsectors[num],
false, false,
*rover->bottomheight, *rover->bottomheight,
@ -3701,10 +3688,9 @@ static void HWR_Subsector(size_t num)
} }
else else
{ {
HWR_GetFlat(levelflats[*rover->bottompic].lumpnum); HWR_GetFlat(&levelflats[*rover->bottompic]);
HWR_GetTextureFlat(levelflats[*rover->bottompic].texturenum);
light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false);
HWR_RenderPlane(NULL, &extrasubsectors[num], false, *rover->bottomheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, levelflats[*rover->bottompic].texturenum, HWR_RenderPlane(NULL, &extrasubsectors[num], false, *rover->bottomheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, &levelflats[*rover->bottompic],
rover->master->frontsector, 255, false, *gr_frontsector->lightlist[light].extra_colormap); rover->master->frontsector, 255, false, *gr_frontsector->lightlist[light].extra_colormap);
} }
} }
@ -3736,7 +3722,7 @@ static void HWR_Subsector(size_t num)
else else
alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, NORMALFOG); alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, NORMALFOG);
HWR_AddTransparentFloor(0, 0, HWR_AddTransparentFloor(NULL,
&extrasubsectors[num], &extrasubsectors[num],
true, true,
*rover->topheight, *rover->topheight,
@ -3754,8 +3740,7 @@ static void HWR_Subsector(size_t num)
*gr_frontsector->lightlist[light].lightlevel, *gr_frontsector->lightlist[light].lightlevel,
rover->alpha-1, rover->master->frontsector); rover->alpha-1, rover->master->frontsector);
#else #else
HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, HWR_AddTransparentFloor(&levelflats[*rover->toppic],
levelflats[*rover->bottompic].texturenum,
&extrasubsectors[num], &extrasubsectors[num],
true, true,
*rover->topheight, *rover->topheight,
@ -3767,10 +3752,9 @@ static void HWR_Subsector(size_t num)
} }
else else
{ {
HWR_GetFlat(levelflats[*rover->toppic].lumpnum); HWR_GetFlat(&levelflats[*rover->toppic]);
HWR_GetTextureFlat(levelflats[*rover->toppic].texturenum);
light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false);
HWR_RenderPlane(NULL, &extrasubsectors[num], true, *rover->topheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, levelflats[*rover->toppic].texturenum, HWR_RenderPlane(NULL, &extrasubsectors[num], true, *rover->topheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, &levelflats[*rover->toppic],
rover->master->frontsector, 255, false, *gr_frontsector->lightlist[light].extra_colormap); rover->master->frontsector, 255, false, *gr_frontsector->lightlist[light].extra_colormap);
} }
} }
@ -5098,8 +5082,7 @@ typedef struct
boolean isceiling; boolean isceiling;
fixed_t fixedheight; fixed_t fixedheight;
INT32 lightlevel; INT32 lightlevel;
lumpnum_t lumpnum; levelflat_t *levelflat;
INT32 texturenum;
INT32 alpha; INT32 alpha;
sector_t *FOFSector; sector_t *FOFSector;
FBITFIELD blend; FBITFIELD blend;
@ -5117,8 +5100,7 @@ typedef struct
boolean isceiling; boolean isceiling;
fixed_t fixedheight; fixed_t fixedheight;
INT32 lightlevel; INT32 lightlevel;
lumpnum_t lumpnum; levelflat_t *levelflat;
INT32 texturenum;
INT32 alpha; INT32 alpha;
sector_t *FOFSector; sector_t *FOFSector;
FBITFIELD blend; FBITFIELD blend;
@ -5149,7 +5131,7 @@ static INT32 drawcount = 0;
#define MAX_TRANSPARENTFLOOR 512 #define MAX_TRANSPARENTFLOOR 512
// This will likely turn into a copy of HWR_Add3DWater and replace it. // This will likely turn into a copy of HWR_Add3DWater and replace it.
void HWR_AddTransparentFloor(lumpnum_t lumpnum, INT32 texturenum, extrasubsector_t *xsub, boolean isceiling, void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boolean isceiling,
fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap) fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap)
{ {
static size_t allocedplanes = 0; static size_t allocedplanes = 0;
@ -5167,8 +5149,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, INT32 texturenum, extrasubsector
planeinfo[numplanes].isceiling = isceiling; planeinfo[numplanes].isceiling = isceiling;
planeinfo[numplanes].fixedheight = fixedheight; planeinfo[numplanes].fixedheight = fixedheight;
planeinfo[numplanes].lightlevel = lightlevel; planeinfo[numplanes].lightlevel = lightlevel;
planeinfo[numplanes].lumpnum = lumpnum; planeinfo[numplanes].levelflat = levelflat;
planeinfo[numplanes].texturenum = texturenum;
planeinfo[numplanes].xsub = xsub; planeinfo[numplanes].xsub = xsub;
planeinfo[numplanes].alpha = alpha; planeinfo[numplanes].alpha = alpha;
planeinfo[numplanes].FOFSector = FOFSector; planeinfo[numplanes].FOFSector = FOFSector;
@ -5182,7 +5163,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, INT32 texturenum, extrasubsector
// Adding this for now until I can create extrasubsector info for polyobjects // Adding this for now until I can create extrasubsector info for polyobjects
// When that happens it'll just be done through HWR_AddTransparentFloor and HWR_RenderPlane // When that happens it'll just be done through HWR_AddTransparentFloor and HWR_RenderPlane
void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, INT32 texturenum, polyobj_t *polysector, boolean isceiling, void HWR_AddTransparentPolyobjectFloor(levelflat_t *levelflat, polyobj_t *polysector, boolean isceiling,
fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap) fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap)
{ {
static size_t allocedpolyplanes = 0; static size_t allocedpolyplanes = 0;
@ -5200,8 +5181,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, INT32 texturenum, poly
polyplaneinfo[numpolyplanes].isceiling = isceiling; polyplaneinfo[numpolyplanes].isceiling = isceiling;
polyplaneinfo[numpolyplanes].fixedheight = fixedheight; polyplaneinfo[numpolyplanes].fixedheight = fixedheight;
polyplaneinfo[numpolyplanes].lightlevel = lightlevel; polyplaneinfo[numpolyplanes].lightlevel = lightlevel;
polyplaneinfo[numpolyplanes].lumpnum = lumpnum; polyplaneinfo[numpolyplanes].levelflat = levelflat;
polyplaneinfo[numpolyplanes].texturenum = texturenum;
polyplaneinfo[numpolyplanes].polysector = polysector; polyplaneinfo[numpolyplanes].polysector = polysector;
polyplaneinfo[numpolyplanes].alpha = alpha; polyplaneinfo[numpolyplanes].alpha = alpha;
polyplaneinfo[numpolyplanes].FOFSector = FOFSector; polyplaneinfo[numpolyplanes].FOFSector = FOFSector;
@ -5363,12 +5343,9 @@ static void HWR_CreateDrawNodes(void)
gr_frontsector = NULL; gr_frontsector = NULL;
if (!(sortnode[sortindex[i]].plane->blend & PF_NoTexture)) if (!(sortnode[sortindex[i]].plane->blend & PF_NoTexture))
{ HWR_GetFlat(sortnode[sortindex[i]].plane->levelflat);
HWR_GetFlat(sortnode[sortindex[i]].plane->lumpnum);
HWR_GetTextureFlat(sortnode[sortindex[i]].plane->texturenum);
}
HWR_RenderPlane(NULL, sortnode[sortindex[i]].plane->xsub, sortnode[sortindex[i]].plane->isceiling, sortnode[sortindex[i]].plane->fixedheight, sortnode[sortindex[i]].plane->blend, sortnode[sortindex[i]].plane->lightlevel, HWR_RenderPlane(NULL, sortnode[sortindex[i]].plane->xsub, sortnode[sortindex[i]].plane->isceiling, sortnode[sortindex[i]].plane->fixedheight, sortnode[sortindex[i]].plane->blend, sortnode[sortindex[i]].plane->lightlevel,
sortnode[sortindex[i]].plane->lumpnum, sortnode[sortindex[i]].plane->texturenum, sortnode[sortindex[i]].plane->FOFSector, sortnode[sortindex[i]].plane->alpha, sortnode[sortindex[i]].plane->fogplane, sortnode[sortindex[i]].plane->planecolormap); sortnode[sortindex[i]].plane->levelflat, sortnode[sortindex[i]].plane->FOFSector, sortnode[sortindex[i]].plane->alpha, sortnode[sortindex[i]].plane->fogplane, sortnode[sortindex[i]].plane->planecolormap);
} }
else if (sortnode[sortindex[i]].polyplane) else if (sortnode[sortindex[i]].polyplane)
{ {
@ -5376,12 +5353,9 @@ static void HWR_CreateDrawNodes(void)
gr_frontsector = NULL; gr_frontsector = NULL;
if (!(sortnode[sortindex[i]].polyplane->blend & PF_NoTexture)) if (!(sortnode[sortindex[i]].polyplane->blend & PF_NoTexture))
{ HWR_GetFlat(sortnode[sortindex[i]].polyplane->levelflat);
HWR_GetFlat(sortnode[sortindex[i]].polyplane->lumpnum);
HWR_GetTextureFlat(sortnode[sortindex[i]].polyplane->texturenum);
}
HWR_RenderPolyObjectPlane(sortnode[sortindex[i]].polyplane->polysector, sortnode[sortindex[i]].polyplane->isceiling, sortnode[sortindex[i]].polyplane->fixedheight, sortnode[sortindex[i]].polyplane->blend, sortnode[sortindex[i]].polyplane->lightlevel, HWR_RenderPolyObjectPlane(sortnode[sortindex[i]].polyplane->polysector, sortnode[sortindex[i]].polyplane->isceiling, sortnode[sortindex[i]].polyplane->fixedheight, sortnode[sortindex[i]].polyplane->blend, sortnode[sortindex[i]].polyplane->lightlevel,
sortnode[sortindex[i]].polyplane->lumpnum, sortnode[sortindex[i]].polyplane->texturenum, sortnode[sortindex[i]].polyplane->FOFSector, sortnode[sortindex[i]].polyplane->alpha, sortnode[sortindex[i]].polyplane->planecolormap); sortnode[sortindex[i]].polyplane->levelflat, sortnode[sortindex[i]].polyplane->FOFSector, sortnode[sortindex[i]].polyplane->alpha, sortnode[sortindex[i]].polyplane->planecolormap);
} }
else if (sortnode[sortindex[i]].wall) else if (sortnode[sortindex[i]].wall)
{ {
@ -6752,7 +6726,7 @@ static void HWR_Render3DWater(void)
gr_frontsector = NULL; //Hurdler: gr_fronsector is no longer valid gr_frontsector = NULL; //Hurdler: gr_fronsector is no longer valid
for (i = 0; i < numfloors; i++) for (i = 0; i < numfloors; i++)
{ {
HWR_GetFlat(planeinfo[i].lumpnum); HWR_GetFlat(planeinfo[i].levelflat);
HWR_RenderPlane(NULL, planeinfo[i].xsub, planeinfo[i].isceiling, planeinfo[i].fixedheight, PF_Translucent, planeinfo[i].lightlevel, planeinfo[i].lumpnum, HWR_RenderPlane(NULL, planeinfo[i].xsub, planeinfo[i].isceiling, planeinfo[i].fixedheight, PF_Translucent, planeinfo[i].lightlevel, planeinfo[i].lumpnum,
planeinfo[i].FOFSector, planeinfo[i].alpha, planeinfo[i].fogplane, planeinfo[i].planecolormap); planeinfo[i].FOFSector, planeinfo[i].alpha, planeinfo[i].fogplane, planeinfo[i].planecolormap);
} }