mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
FIX COLOR BUG
This commit is contained in:
parent
7dac10f5f9
commit
07d71778dc
6 changed files with 33 additions and 35 deletions
|
@ -48,7 +48,6 @@ struct GLMipmap_s
|
||||||
|
|
||||||
struct GLMipmap_s *nextcolormap;
|
struct GLMipmap_s *nextcolormap;
|
||||||
const UINT8 *colormap;
|
const UINT8 *colormap;
|
||||||
INT32 tcindex;
|
|
||||||
|
|
||||||
// opengl
|
// opengl
|
||||||
struct GLMipmap_s *nextmipmap; // opengl : liste of all texture in opengl driver
|
struct GLMipmap_s *nextmipmap; // opengl : liste of all texture in opengl driver
|
||||||
|
|
|
@ -1020,32 +1020,13 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
|
||||||
// mostly copied from HWR_GetMappedPatch, hence the similarities and comment
|
// mostly copied from HWR_GetMappedPatch, hence the similarities and comment
|
||||||
GLMipmap_t *grmip, *newmip;
|
GLMipmap_t *grmip, *newmip;
|
||||||
|
|
||||||
if ((colormap == colormaps || colormap == NULL) && (skinnum > TC_DEFAULT))
|
if (colormap == colormaps || colormap == NULL)
|
||||||
{
|
{
|
||||||
// Don't do any blending
|
// Don't do any blending
|
||||||
HWD.pfnSetTexture(gpatch->mipmap);
|
HWD.pfnSetTexture(gpatch->mipmap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// search for the mipmap
|
|
||||||
// skip the first (no colormap translated)
|
|
||||||
for (grmip = gpatch->mipmap; grmip->nextcolormap; )
|
|
||||||
{
|
|
||||||
grmip = grmip->nextcolormap;
|
|
||||||
if (grmip->colormap == colormap || (skinnum < TC_DEFAULT && grmip->tcindex == skinnum))
|
|
||||||
{
|
|
||||||
if (grmip->downloaded && grmip->grInfo.data)
|
|
||||||
{
|
|
||||||
HWD.pfnSetTexture(grmip); // found the colormap, set it to the correct texture
|
|
||||||
Z_ChangeTag(grmip->grInfo.data, PU_HWRMODELTEXTURE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If here, the blended texture has not been created
|
|
||||||
// So we create it
|
|
||||||
|
|
||||||
if ((blendgpatch && blendgpatch->mipmap->grInfo.format)
|
if ((blendgpatch && blendgpatch->mipmap->grInfo.format)
|
||||||
&& (gpatch->width != blendgpatch->width || gpatch->height != blendgpatch->height))
|
&& (gpatch->width != blendgpatch->width || gpatch->height != blendgpatch->height))
|
||||||
{
|
{
|
||||||
|
@ -1054,21 +1035,39 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// search for the mipmap
|
||||||
|
// skip the first (no colormap translated)
|
||||||
|
for (grmip = gpatch->mipmap; grmip->nextcolormap; )
|
||||||
|
{
|
||||||
|
grmip = grmip->nextcolormap;
|
||||||
|
if (grmip->colormap == colormap)
|
||||||
|
{
|
||||||
|
if (grmip->downloaded && grmip->grInfo.data)
|
||||||
|
{
|
||||||
|
HWD.pfnSetTexture(grmip); // found the colormap, set it to the correct texture
|
||||||
|
Z_ChangeTag(grmip->grInfo.data, PU_HWRMODELTEXTURE_UNLOCKED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If here, the blended texture has not been created
|
||||||
|
// So we create it
|
||||||
|
|
||||||
//BP: WARNING: don't free it manually without clearing the cache of harware renderer
|
//BP: WARNING: don't free it manually without clearing the cache of harware renderer
|
||||||
// (it have a liste of mipmap)
|
// (it have a liste of mipmap)
|
||||||
// this malloc is cleared in HWR_FreeTextureCache
|
// this malloc is cleared in HWR_FreeTextureCache
|
||||||
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
|
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
|
||||||
newmip = calloc(1, sizeof (*newmip));
|
newmip = calloc(1, sizeof (*newmip));
|
||||||
if (newmip == NULL)
|
if (newmip == NULL)
|
||||||
I_Error("%s: Out of memory", "HWR_GetMappedPatch");
|
I_Error("%s: Out of memory", "HWR_GetBlendedTexture");
|
||||||
grmip->nextcolormap = newmip;
|
grmip->nextcolormap = newmip;
|
||||||
newmip->colormap = colormap;
|
newmip->colormap = colormap;
|
||||||
newmip->tcindex = skinnum;
|
|
||||||
|
|
||||||
HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color);
|
HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color);
|
||||||
|
|
||||||
HWD.pfnSetTexture(newmip);
|
HWD.pfnSetTexture(newmip);
|
||||||
Z_ChangeTag(newmip->grInfo.data, PU_HWRMODELTEXTURE);
|
Z_ChangeTag(newmip->grInfo.data, PU_HWRMODELTEXTURE_UNLOCKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NORMALFOG 0x00000000
|
#define NORMALFOG 0x00000000
|
||||||
|
@ -1298,7 +1297,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
|
||||||
|
|
||||||
if (gpatch && gpatch->mipmap->grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
|
if (gpatch && gpatch->mipmap->grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
|
||||||
{
|
{
|
||||||
INT32 skinnum = INT32_MAX;
|
INT32 skinnum = TC_DEFAULT;
|
||||||
|
|
||||||
if ((spr->mobj->flags & (MF_ENEMY|MF_BOSS)) && (spr->mobj->flags2 & MF2_FRET) && !(spr->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash"
|
if ((spr->mobj->flags & (MF_ENEMY|MF_BOSS)) && (spr->mobj->flags2 & MF2_FRET) && !(spr->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash"
|
||||||
{
|
{
|
||||||
|
@ -1329,15 +1328,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translation or skin number found
|
// Translation or skin number found
|
||||||
if (skinnum != INT32_MAX)
|
HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolors_t)spr->mobj->color);
|
||||||
{
|
|
||||||
HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolors_t)spr->mobj->color);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Sorry nothing
|
|
||||||
HWD.pfnSetTexture(gpatch->mipmap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -3699,10 +3699,15 @@ void HWR_SetupLevel(void)
|
||||||
// Meaning, they had memory allocated and marked with the PU_LEVEL tag.
|
// Meaning, they had memory allocated and marked with the PU_LEVEL tag.
|
||||||
// Level textures are only reloaded after R_LoadTextures, which is
|
// Level textures are only reloaded after R_LoadTextures, which is
|
||||||
// when the texture list is loaded.
|
// when the texture list is loaded.
|
||||||
|
|
||||||
|
// Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug.
|
||||||
|
HWR_FreeMipmapCache();
|
||||||
|
|
||||||
#ifdef ALAM_LIGHTING
|
#ifdef ALAM_LIGHTING
|
||||||
// BP: reset light between levels (we draw preview frame lights on current frame)
|
// BP: reset light between levels (we draw preview frame lights on current frame)
|
||||||
HWR_ResetLights();
|
HWR_ResetLights();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Correct missing sidedefs & deep water trick
|
// Correct missing sidedefs & deep water trick
|
||||||
HWR_CorrectSWTricks();
|
HWR_CorrectSWTricks();
|
||||||
HWR_CreatePlanePolygons((INT32)numnodes - 1);
|
HWR_CreatePlanePolygons((INT32)numnodes - 1);
|
||||||
|
|
|
@ -1475,7 +1475,7 @@ void W_FlushCachedPatches(void)
|
||||||
Z_FreeTag(PU_HWRPATCHINFO);
|
Z_FreeTag(PU_HWRPATCHINFO);
|
||||||
Z_FreeTag(PU_HWRMODELTEXTURE);
|
Z_FreeTag(PU_HWRMODELTEXTURE);
|
||||||
Z_FreeTag(PU_HWRCACHE);
|
Z_FreeTag(PU_HWRCACHE);
|
||||||
Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRPATCHINFO_UNLOCKED);
|
Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRMODELTEXTURE_UNLOCKED);
|
||||||
}
|
}
|
||||||
needpatchflush = false;
|
needpatchflush = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -519,6 +519,7 @@ void Z_FlushCachedPatches(void)
|
||||||
Z_FreeTag(PU_HWRCACHE);
|
Z_FreeTag(PU_HWRCACHE);
|
||||||
Z_FreeTag(PU_HWRCACHE_UNLOCKED);
|
Z_FreeTag(PU_HWRCACHE_UNLOCKED);
|
||||||
Z_FreeTag(PU_HWRPATCHINFO_UNLOCKED);
|
Z_FreeTag(PU_HWRPATCHINFO_UNLOCKED);
|
||||||
|
Z_FreeTag(PU_HWRMODELTEXTURE_UNLOCKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// happens before a renderer switch
|
// happens before a renderer switch
|
||||||
|
@ -816,6 +817,7 @@ static void Command_Memfree_f(void)
|
||||||
CONS_Printf(M_GetText("HW Texture cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10));
|
CONS_Printf(M_GetText("HW Texture cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10));
|
||||||
CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10));
|
CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10));
|
||||||
CONS_Printf(M_GetText("HW Texture used : %7d KB\n"), HWR_GetTextureUsed()>>10);
|
CONS_Printf(M_GetText("HW Texture used : %7d KB\n"), HWR_GetTextureUsed()>>10);
|
||||||
|
CONS_Printf(M_GetText("HW model textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRMODELTEXTURE)>>10));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ enum
|
||||||
// 'second-level' cache for graphics
|
// 'second-level' cache for graphics
|
||||||
// stored in hardware format and downloaded as needed
|
// stored in hardware format and downloaded as needed
|
||||||
PU_HWRPATCHINFO_UNLOCKED = 103, // 'unlocked' PU_HWRPATCHINFO memory
|
PU_HWRPATCHINFO_UNLOCKED = 103, // 'unlocked' PU_HWRPATCHINFO memory
|
||||||
|
PU_HWRMODELTEXTURE_UNLOCKED = 104, // 'unlocked' PU_HWRMODELTEXTURE memory
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue