diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index d49531bd..956b6ade 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -379,6 +379,14 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) grtex->mipmap.height = (UINT16)blockheight; grtex->mipmap.grInfo.format = textureformat; + grtex->mipmap.colormap = colormaps; + +#ifdef GLENCORE + if (encoremap) + grtex->mipmap.colormap += (256*32); +#endif + + block = MakeBlock(&grtex->mipmap); if (skyspecial) //Hurdler: not efficient, but better than holes in the sky (and it's done only at level loading) @@ -613,6 +621,12 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) { size_t size, pflatsize; +#ifdef GLENCORE + UINT8 *flat; + UINT32 steppy; +#endif + + // setup the texture info grMipmap->grInfo.smallLodLog2 = GR_LOD_LOG2_64; grMipmap->grInfo.largeLodLog2 = GR_LOD_LOG2_64; @@ -652,16 +666,31 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) // the flat raw data needn't be converted with palettized textures W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum), PU_HWRCACHE, &grMipmap->grInfo.data)); + +#ifdef GLENCORE + flat = grMipmap->grInfo.data; + for (steppy = 0; steppy < size; steppy++) + if (flat[steppy] != HWR_PATCHES_CHROMAKEY_COLORINDEX) + flat[steppy] = grMipmap->colormap[flat[steppy]]; +#endif } // Download a Doom 'flat' to the hardware cache and make it ready for use -void HWR_GetFlat(lumpnum_t flatlumpnum) +void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) { GLMipmap_t *grmip; grmip = &HWR_GetCachedGLPatch(flatlumpnum)->mipmap; + grmip->colormap = colormaps; + +#ifdef GLENCORE + if (!noencoremap && encoremap) + grmip->colormap += (256*32); +#endif + + if (!grmip->downloaded && !grmip->grInfo.data) HWR_CacheFlat(grmip, flatlumpnum); diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index b39103ee..ac63df15 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -568,7 +568,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[2].tow = v[3].tow = (float)(v[0].tow + h/dflatsize); - HWR_GetFlat(flatlumpnum); + HWR_GetFlat(flatlumpnum, false); //Hurdler: Boris, the same comment as above... but maybe for pics // it not a problem since they don't have any transparent pixel diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 9656e54e..2fb7cff7 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -100,7 +100,9 @@ void HWR_InitTextureCache(void); void HWR_FreeTextureCache(void); void HWR_FreeExtraSubsectors(void); -void HWR_GetFlat(lumpnum_t flatlumpnum); +void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencore); +// ^ some flats must NOT be remapped to encore, since we remap them as we cache them for ease, adding a toggle here seems wise. + GLTexture_t *HWR_GetTexture(INT32 tex); void HWR_GetPatch(GLPatch_t *gpatch); void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 6a08b1c7..fd112c29 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -30,7 +30,7 @@ #include "../p_local.h" #include "../p_setup.h" #include "../r_local.h" -#include "../r_bsp.h" +#include "../r_bsp.h" // R_NoEncore #include "../d_clisrv.h" #include "../w_wad.h" #include "../z_zone.h" @@ -3397,7 +3397,7 @@ static void HWR_AddPolyObjectPlanes(void) } else { - HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum); + HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum, R_NoEncore(polyobjsector, false)); HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude, polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum, polyobjsector, 255, NULL); @@ -3419,7 +3419,7 @@ static void HWR_AddPolyObjectPlanes(void) } else { - HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum); + HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum, R_NoEncore(polyobjsector, false)); HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude, polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum, polyobjsector, 255, NULL); @@ -3572,7 +3572,7 @@ static void HWR_Subsector(size_t num) { if (sub->validcount != validcount) { - HWR_GetFlat(levelflats[gr_frontsector->floorpic].lumpnum); + HWR_GetFlat(levelflats[gr_frontsector->floorpic].lumpnum, R_NoEncore(gr_frontsector, false)); HWR_RenderPlane(gr_frontsector, &extrasubsectors[num], false, // Hack to make things continue to work around slopes. locFloorHeight == cullFloorHeight ? locFloorHeight : gr_frontsector->floorheight, @@ -3594,7 +3594,7 @@ static void HWR_Subsector(size_t num) { if (sub->validcount != validcount) { - HWR_GetFlat(levelflats[gr_frontsector->ceilingpic].lumpnum); + HWR_GetFlat(levelflats[gr_frontsector->ceilingpic].lumpnum, R_NoEncore(gr_frontsector, false)); HWR_RenderPlane(NULL, &extrasubsectors[num], true, // Hack to make things continue to work around slopes. locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gr_frontsector->ceilingheight, @@ -3687,7 +3687,7 @@ static void HWR_Subsector(size_t num) } else { - HWR_GetFlat(levelflats[*rover->bottompic].lumpnum); + HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gr_frontsector, 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, rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap); @@ -3751,7 +3751,7 @@ static void HWR_Subsector(size_t num) } else { - HWR_GetFlat(levelflats[*rover->toppic].lumpnum); + HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gr_frontsector, 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, rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap); @@ -5348,7 +5348,7 @@ static void HWR_CreateDrawNodes(void) gr_frontsector = NULL; if (!(sortnode[sortindex[i]].plane->blend & PF_NoTexture)) - HWR_GetFlat(sortnode[sortindex[i]].plane->lumpnum); + HWR_GetFlat(sortnode[sortindex[i]].plane->lumpnum, R_NoEncore(sortnode[sortindex[i]].plane->FOFSector, sortnode[sortindex[i]].plane->isceiling)); 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->FOFSector, sortnode[sortindex[i]].plane->alpha, sortnode[sortindex[i]].plane->fogplane, sortnode[sortindex[i]].plane->planecolormap); } @@ -5358,7 +5358,7 @@ static void HWR_CreateDrawNodes(void) gr_frontsector = NULL; if (!(sortnode[sortindex[i]].polyplane->blend & PF_NoTexture)) - HWR_GetFlat(sortnode[sortindex[i]].polyplane->lumpnum); + HWR_GetFlat(sortnode[sortindex[i]].polyplane->lumpnum, R_NoEncore(sortnode[sortindex[i]].polyplane->FOFSector, sortnode[sortindex[i]].polyplane->isceiling)); 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->FOFSector, sortnode[sortindex[i]].polyplane->alpha, sortnode[sortindex[i]].polyplane->planecolormap); } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 7bc361d9..e6c1fb6f 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -17,6 +17,8 @@ /// \file /// \brief 3D render mode functions +#define GLENCORE + #ifndef __HWR_MAIN_H__ #define __HWR_MAIN_H__ diff --git a/src/r_bsp.c b/src/r_bsp.c index 296cbbe8..43cb6432 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -37,7 +37,7 @@ drawseg_t *ds_p = NULL; // indicates doors closed wrt automap bugfix: INT32 doorclosed; -static boolean R_NoEncore(sector_t *sector, boolean ceiling) +boolean R_NoEncore(sector_t *sector, boolean ceiling) { boolean invertencore = (GETSECSPECIAL(sector->special, 2) == 15); #if 0 // perfect implementation diff --git a/src/r_bsp.h b/src/r_bsp.h index e3662e2e..3350ce8e 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -40,6 +40,11 @@ void R_ClearDrawSegs(void); void R_RenderBSPNode(INT32 bspnum); void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2); +// determines when a given sector shouldn't abide by the encoremap's palette. +// no longer a static since this is used for encore in hw_main.c as well now: +boolean R_NoEncore(sector_t *sector, boolean ceiling); + + #ifdef POLYOBJECTS void R_SortPolyObjects(subsector_t *sub);