mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Factor out commonly occuring hictinting[]-accessing code into three functions.
Note: in polymer.c, this was buggy (but harmless) because .r is a char: if ((uint32_t)hictinting[MAXPALOOKUPS-1].r & 0xFFFFFF00) != 0xFFFFFF00) git-svn-id: https://svn.eduke32.com/eduke32@4487 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
69c867b8e3
commit
6fb9929f44
4 changed files with 44 additions and 101 deletions
|
@ -36,6 +36,27 @@ typedef struct texcachepic_t
|
|||
|
||||
hicreplctyp * hicfindsubst(int picnum, int palnum, int skybox);
|
||||
|
||||
static inline int have_basepal_tint(void)
|
||||
{
|
||||
return (hictinting[MAXPALOOKUPS-1].r != 255 ||
|
||||
hictinting[MAXPALOOKUPS-1].g != 255 ||
|
||||
hictinting[MAXPALOOKUPS-1].b != 255);
|
||||
}
|
||||
|
||||
static inline void hictinting_apply(float *color, int32_t palnum)
|
||||
{
|
||||
color[0] *= (float)hictinting[palnum].r / 255.0;
|
||||
color[1] *= (float)hictinting[palnum].g / 255.0;
|
||||
color[2] *= (float)hictinting[palnum].b / 255.0;
|
||||
}
|
||||
|
||||
static inline void hictinting_apply_ub(uint8_t *color, int32_t palnum)
|
||||
{
|
||||
color[0] *= (float)hictinting[palnum].r / 255.0;
|
||||
color[1] *= (float)hictinting[palnum].g / 255.0;
|
||||
color[2] *= (float)hictinting[palnum].b / 255.0;
|
||||
}
|
||||
|
||||
// texcacheheader cachead.flags bits
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -2172,15 +2172,10 @@ static int32_t md3draw(md3model_t *m, const spritetype *tspr)
|
|||
{
|
||||
if (!(m->flags&1) || (((unsigned)owner < MAXSPRITES) && sector[sprite[owner].sectnum].floorpal!=0))
|
||||
{
|
||||
pc[0] *= (float)hictinting[globalpal].r / 255.0;
|
||||
pc[1] *= (float)hictinting[globalpal].g / 255.0;
|
||||
pc[2] *= (float)hictinting[globalpal].b / 255.0;
|
||||
if (hictinting[MAXPALOOKUPS-1].r != 255 || hictinting[MAXPALOOKUPS-1].g != 255 || hictinting[MAXPALOOKUPS-1].b != 255)
|
||||
{
|
||||
pc[0] *= (float)hictinting[MAXPALOOKUPS-1].r / 255.0f;
|
||||
pc[1] *= (float)hictinting[MAXPALOOKUPS-1].g / 255.0f;
|
||||
pc[2] *= (float)hictinting[MAXPALOOKUPS-1].b / 255.0f;
|
||||
}
|
||||
hictinting_apply(pc, globalpal);
|
||||
|
||||
if (have_basepal_tint())
|
||||
hictinting_apply(pc, MAXPALOOKUPS-1);
|
||||
}
|
||||
else globalnoeffect=1;
|
||||
}
|
||||
|
@ -3278,9 +3273,8 @@ int32_t voxdraw(voxmodel_t *m, const spritetype *tspr)
|
|||
bglEnable(GL_TEXTURE_2D);
|
||||
|
||||
pc[0] = pc[1] = pc[2] = ((float)(numshades-min(max((globalshade * shadescale)+m->shadeoff,0),numshades)))/((float)numshades);
|
||||
pc[0] *= (float)hictinting[globalpal].r / 255.0;
|
||||
pc[1] *= (float)hictinting[globalpal].g / 255.0;
|
||||
pc[2] *= (float)hictinting[globalpal].b / 255.0;
|
||||
hictinting_apply(pc, globalpal);
|
||||
|
||||
if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66f; else pc[3] = 0.33f; }
|
||||
else pc[3] = 1.0f;
|
||||
pc[3] *= 1.0f - spriteext[tspr->owner].alpha;
|
||||
|
|
|
@ -3927,20 +3927,10 @@ static void polymer_drawartsky(int16_t tilenum, char palnum, int8_t shad
|
|||
if (pth && (pth->flags & PTH_HIGHTILE))
|
||||
{
|
||||
if (pth->palnum != palnum)
|
||||
{
|
||||
glcolors[i][0] *= (float)hictinting[palnum].r / 255.0;
|
||||
glcolors[i][1] *= (float)hictinting[palnum].g / 255.0;
|
||||
glcolors[i][2] *= (float)hictinting[palnum].b / 255.0;
|
||||
}
|
||||
hictinting_apply(glcolors[i], palnum);
|
||||
|
||||
if (hictinting[MAXPALOOKUPS-1].r != 255 ||
|
||||
hictinting[MAXPALOOKUPS-1].g != 255 ||
|
||||
hictinting[MAXPALOOKUPS-1].b != 255)
|
||||
{
|
||||
glcolors[i][0] *= (float)hictinting[MAXPALOOKUPS-1].r / 255.0;
|
||||
glcolors[i][1] *= (float)hictinting[MAXPALOOKUPS-1].g / 255.0;
|
||||
glcolors[i][2] *= (float)hictinting[MAXPALOOKUPS-1].b / 255.0;
|
||||
}
|
||||
if (have_basepal_tint())
|
||||
hictinting_apply(glcolors[i], MAXPALOOKUPS-1);
|
||||
}
|
||||
|
||||
i++;
|
||||
|
@ -4018,20 +4008,10 @@ static void polymer_drawskybox(int16_t tilenum, char palnum, int8_t shad
|
|||
if (pth && (pth->flags & PTH_HIGHTILE))
|
||||
{
|
||||
if (pth->palnum != palnum)
|
||||
{
|
||||
color[0] *= (float)hictinting[palnum].r / 255.0;
|
||||
color[1] *= (float)hictinting[palnum].g / 255.0;
|
||||
color[2] *= (float)hictinting[palnum].b / 255.0;
|
||||
}
|
||||
hictinting_apply(color, palnum);
|
||||
|
||||
if (hictinting[MAXPALOOKUPS-1].r != 255 ||
|
||||
hictinting[MAXPALOOKUPS-1].g != 255 ||
|
||||
hictinting[MAXPALOOKUPS-1].b != 255)
|
||||
{
|
||||
color[0] *= (float)hictinting[MAXPALOOKUPS-1].r / 255.0;
|
||||
color[1] *= (float)hictinting[MAXPALOOKUPS-1].g / 255.0;
|
||||
color[2] *= (float)hictinting[MAXPALOOKUPS-1].b / 255.0;
|
||||
}
|
||||
if (have_basepal_tint())
|
||||
hictinting_apply(color, MAXPALOOKUPS-1);
|
||||
}
|
||||
|
||||
bglColor4f(color[0], color[1], color[2], 1.0);
|
||||
|
@ -4250,34 +4230,13 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
|||
if (!usinghighpal && !(hictinting[tspr->pal].f & HICTINT_COLORIZE))
|
||||
{
|
||||
if (!(m->flags&1) || (!(tspr->owner >= MAXSPRITES) && sector[sprite[tspr->owner].sectnum].floorpal!=0))
|
||||
{
|
||||
double f;
|
||||
|
||||
f = color[0] * (float)hictinting[tspr->pal].r / 255.0;
|
||||
color[0] = (GLubyte)f;
|
||||
f = color[1] * (float)hictinting[tspr->pal].g / 255.0;
|
||||
color[1] = (GLubyte)f;
|
||||
f = color[2] * (float)hictinting[tspr->pal].b / 255.0;
|
||||
color[2] = (GLubyte)f;
|
||||
}
|
||||
hictinting_apply_ub(color, tspr->pal);
|
||||
else globalnoeffect=1; //mdloadskin reads this
|
||||
}
|
||||
|
||||
// fullscreen tint on global palette change
|
||||
if (!usinghighpal &&
|
||||
(hictinting[MAXPALOOKUPS-1].r != 255 ||
|
||||
hictinting[MAXPALOOKUPS-1].g != 255 ||
|
||||
hictinting[MAXPALOOKUPS-1].b != 255))
|
||||
{
|
||||
double f;
|
||||
|
||||
f = color[0] * hictinting[MAXPALOOKUPS-1].r / 255.0;
|
||||
color[0] = (GLubyte)f;
|
||||
f = color[1] * hictinting[MAXPALOOKUPS-1].g / 255.0;
|
||||
color[1] = (GLubyte)f;
|
||||
f = color[2] * hictinting[MAXPALOOKUPS-1].b / 255.0;
|
||||
color[2] = (GLubyte)f;
|
||||
}
|
||||
if (!usinghighpal && have_basepal_tint())
|
||||
hictinting_apply_ub(color, MAXPALOOKUPS-1);
|
||||
|
||||
if (tspr->cstat & 2)
|
||||
{
|
||||
|
@ -4742,30 +4701,11 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
|
|||
if (pth->flags & PTH_HIGHTILE)
|
||||
{
|
||||
if (pth->palnum != pal)
|
||||
{
|
||||
double f;
|
||||
|
||||
f = material->diffusemodulation[0] * (float)hictinting[pal].r / 255.0;
|
||||
material->diffusemodulation[0] = (GLubyte)f;
|
||||
f = material->diffusemodulation[1] * (float)hictinting[pal].g / 255.0;
|
||||
material->diffusemodulation[1] = (GLubyte)f;
|
||||
f = material->diffusemodulation[2] * (float)hictinting[pal].b / 255.0;
|
||||
material->diffusemodulation[2] = (GLubyte)f;
|
||||
}
|
||||
hictinting_apply_ub(material->diffusemodulation, pal);
|
||||
|
||||
// fullscreen tint on global palette change... this is used for nightvision and underwater tinting
|
||||
// if ((hictinting[MAXPALOOKUPS-1].r + hictinting[MAXPALOOKUPS-1].g + hictinting[MAXPALOOKUPS-1].b) != 0x2FD)
|
||||
if (!usinghighpal && ((uint32_t)hictinting[MAXPALOOKUPS-1].r & 0xFFFFFF00) != 0xFFFFFF00)
|
||||
{
|
||||
double f;
|
||||
|
||||
f = material->diffusemodulation[0] * hictinting[MAXPALOOKUPS-1].r / 255.0;
|
||||
material->diffusemodulation[0] = (GLubyte)f;
|
||||
f = material->diffusemodulation[1] * hictinting[MAXPALOOKUPS-1].g / 255.0;
|
||||
material->diffusemodulation[1] = (GLubyte)f;
|
||||
f = material->diffusemodulation[2] * hictinting[MAXPALOOKUPS-1].b / 255.0;
|
||||
material->diffusemodulation[2] = (GLubyte)f;
|
||||
}
|
||||
if (!usinghighpal && have_basepal_tint())
|
||||
hictinting_apply_ub(material->diffusemodulation, MAXPALOOKUPS-1);
|
||||
}
|
||||
|
||||
// PR_BIT_GLOW_MAP
|
||||
|
|
|
@ -1605,26 +1605,14 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
|
|||
if (pth && (pth->flags & PTH_HIGHTILE))
|
||||
{
|
||||
if (pth->palnum != globalpal)
|
||||
{
|
||||
// apply tinting for replaced textures
|
||||
pc[0] *= (float)hictinting[globalpal].r / 255.0;
|
||||
pc[1] *= (float)hictinting[globalpal].g / 255.0;
|
||||
pc[2] *= (float)hictinting[globalpal].b / 255.0;
|
||||
}
|
||||
if (hictinting[MAXPALOOKUPS-1].r != 255 || hictinting[MAXPALOOKUPS-1].g != 255 || hictinting[MAXPALOOKUPS-1].b != 255)
|
||||
{
|
||||
pc[0] *= (float)hictinting[MAXPALOOKUPS-1].r / 255.0;
|
||||
pc[1] *= (float)hictinting[MAXPALOOKUPS-1].g / 255.0;
|
||||
pc[2] *= (float)hictinting[MAXPALOOKUPS-1].b / 255.0;
|
||||
}
|
||||
hictinting_apply(pc, globalpal);
|
||||
|
||||
if (have_basepal_tint())
|
||||
hictinting_apply(pc, MAXPALOOKUPS-1);
|
||||
}
|
||||
// hack: this is for drawing the 8-bit crosshair recolored in polymost
|
||||
else if (hictinting[globalpal].f & HICTINT_USEONART)
|
||||
{
|
||||
pc[0] *= (float)hictinting[globalpal].r / 255.0;
|
||||
pc[1] *= (float)hictinting[globalpal].g / 255.0;
|
||||
pc[2] *= (float)hictinting[globalpal].b / 255.0;
|
||||
}
|
||||
hictinting_apply(pc, globalpal);
|
||||
}
|
||||
|
||||
bglColor4f(pc[0],pc[1],pc[2],pc[3]);
|
||||
|
|
Loading…
Reference in a new issue