mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 19:20:46 +00:00
Replace various GL rendering related literal flags with enum labels.
- pthtyp pth->flags bits - Flags of the <dameth> argument of various functions - hictinting[].f / gloadtile_hi() and daskinloader() <effect> arg bits - hicreplctyp hicr->flags bits - texcacheheader cachead.flags bits git-svn-id: https://svn.eduke32.com/eduke32@4486 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
2c84d175ed
commit
69c867b8e3
8 changed files with 126 additions and 60 deletions
|
@ -35,6 +35,32 @@ typedef struct texcachepic_t
|
||||||
} texcachepicture;
|
} texcachepicture;
|
||||||
|
|
||||||
hicreplctyp * hicfindsubst(int picnum, int palnum, int skybox);
|
hicreplctyp * hicfindsubst(int picnum, int palnum, int skybox);
|
||||||
#define HICEFFECTMASK (1|2|4|8)
|
|
||||||
|
// texcacheheader cachead.flags bits
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CACHEAD_NONPOW2 = 1,
|
||||||
|
CACHEAD_HASALPHA = 2,
|
||||||
|
CACHEAD_COMPRESSED = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
// hicreplctyp hicr->flags bits
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
HICR_NOSAVE = 1,
|
||||||
|
|
||||||
|
HICR_NOCOMPRESS = 16,
|
||||||
|
};
|
||||||
|
|
||||||
|
// hictinting[].f / gloadtile_hi() and daskinloader() <effect> arg bits
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
HICTINT_GRAYSCALE = 1,
|
||||||
|
HICTINT_INVERT = 2,
|
||||||
|
HICTINT_COLORIZE = 4,
|
||||||
|
HICTINT_USEONART = 8,
|
||||||
|
|
||||||
|
HICEFFECTMASK = (1|2|4|8),
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -94,6 +94,28 @@ static inline int32_t fogpal_shade(const sectortype *sec, int32_t shade)
|
||||||
return sec->fogpal ? 0 : shade;
|
return sec->fogpal ? 0 : shade;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flags of the <dameth> argument of various functions
|
||||||
|
enum {
|
||||||
|
DAMETH_CLAMPED = 4,
|
||||||
|
|
||||||
|
DAMETH_NOCOMPRESS = 4096,
|
||||||
|
DAMETH_HI = 8192,
|
||||||
|
};
|
||||||
|
|
||||||
|
// DAMETH_CLAMPED -> PTH_CLAMPED conversion
|
||||||
|
#define TO_PTH_CLAMPED(dameth) ((((dameth)&4))>>2)
|
||||||
|
|
||||||
|
// pthtyp pth->flags bits
|
||||||
|
enum {
|
||||||
|
PTH_CLAMPED = 1,
|
||||||
|
PTH_HIGHTILE = 2,
|
||||||
|
PTH_SKYBOX = 4,
|
||||||
|
PTH_HASALPHA = 8,
|
||||||
|
PTH_HASFULLBRIGHT = 16,
|
||||||
|
|
||||||
|
PTH_INVALIDATED = 128,
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct pthtyp_t
|
typedef struct pthtyp_t
|
||||||
{
|
{
|
||||||
struct pthtyp_t *next;
|
struct pthtyp_t *next;
|
||||||
|
|
|
@ -624,20 +624,20 @@ static int32_t daskinloader(int32_t filh, intptr_t *fptr, int32_t *bpl, int32_t
|
||||||
tcol.g = cptr[rpptr[x].g];
|
tcol.g = cptr[rpptr[x].g];
|
||||||
tcol.r = cptr[rpptr[x].r];
|
tcol.r = cptr[rpptr[x].r];
|
||||||
|
|
||||||
if (effect & 1)
|
if (effect & HICTINT_GRAYSCALE)
|
||||||
{
|
{
|
||||||
// greyscale
|
// greyscale
|
||||||
tcol.b = max(tcol.b, max(tcol.g, tcol.r));
|
tcol.b = max(tcol.b, max(tcol.g, tcol.r));
|
||||||
tcol.g = tcol.r = tcol.b;
|
tcol.g = tcol.r = tcol.b;
|
||||||
}
|
}
|
||||||
if (effect & 2)
|
if (effect & HICTINT_INVERT)
|
||||||
{
|
{
|
||||||
// invert
|
// invert
|
||||||
tcol.b = 255-tcol.b;
|
tcol.b = 255-tcol.b;
|
||||||
tcol.g = 255-tcol.g;
|
tcol.g = 255-tcol.g;
|
||||||
tcol.r = 255-tcol.r;
|
tcol.r = 255-tcol.r;
|
||||||
}
|
}
|
||||||
if (effect & 4)
|
if (effect & HICTINT_COLORIZE)
|
||||||
{
|
{
|
||||||
// colorize
|
// colorize
|
||||||
tcol.b = min((int32_t)(tcol.b)*b/64,255);
|
tcol.b = min((int32_t)(tcol.b)*b/64,255);
|
||||||
|
@ -782,7 +782,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
|
||||||
{
|
{
|
||||||
osizx = cachead.xdim;
|
osizx = cachead.xdim;
|
||||||
osizy = cachead.ydim;
|
osizy = cachead.ydim;
|
||||||
hasalpha = (cachead.flags & 2) ? 1 : 0;
|
hasalpha = (cachead.flags & CACHEAD_HASALPHA) ? 1 : 0;
|
||||||
if (pal < (MAXPALOOKUPS - RESERVEDPALS))
|
if (pal < (MAXPALOOKUPS - RESERVEDPALS))
|
||||||
m->usesalpha = hasalpha;
|
m->usesalpha = hasalpha;
|
||||||
//kclose(filh); // FIXME: uncomment when cache1d.c is fixed
|
//kclose(filh); // FIXME: uncomment when cache1d.c is fixed
|
||||||
|
@ -890,7 +890,8 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
|
||||||
if (xsiz == pow2long[j]) { i |= 1; }
|
if (xsiz == pow2long[j]) { i |= 1; }
|
||||||
if (ysiz == pow2long[j]) { i |= 2; }
|
if (ysiz == pow2long[j]) { i |= 2; }
|
||||||
}
|
}
|
||||||
cachead.flags = (i!=3) | (hasalpha ? 2 : 0);
|
cachead.flags = (i!=3)*CACHEAD_NONPOW2 | (hasalpha ? CACHEAD_HASALPHA : 0);
|
||||||
|
|
||||||
/// OSD_Printf("Caching \"%s\"\n",fn);
|
/// OSD_Printf("Caching \"%s\"\n",fn);
|
||||||
texcache_writetex(fn, picfillen, pal<<8, hicfxmask(pal), &cachead);
|
texcache_writetex(fn, picfillen, pal<<8, hicfxmask(pal), &cachead);
|
||||||
|
|
||||||
|
@ -2167,7 +2168,7 @@ static int32_t md3draw(md3model_t *m, const spritetype *tspr)
|
||||||
bglEnable(GL_TEXTURE_2D);
|
bglEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
pc[0] = pc[1] = pc[2] = ((float)(numshades-min(max((globalshade * shadescale)+m->shadeoff,0),numshades)))/((float)numshades);
|
pc[0] = pc[1] = pc[2] = ((float)(numshades-min(max((globalshade * shadescale)+m->shadeoff,0),numshades)))/((float)numshades);
|
||||||
if (!(hictinting[globalpal].f&4))
|
if (!(hictinting[globalpal].f & HICTINT_COLORIZE))
|
||||||
{
|
{
|
||||||
if (!(m->flags&1) || (((unsigned)owner < MAXSPRITES) && sector[sprite[owner].sectnum].floorpal!=0))
|
if (!(m->flags&1) || (((unsigned)owner < MAXSPRITES) && sector[sprite[owner].sectnum].floorpal!=0))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1034,7 +1034,7 @@ void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t da
|
||||||
// if it's not a skybox, make the sky parallax
|
// if it's not a skybox, make the sky parallax
|
||||||
// DEFAULT_ARTSKY_ANGDIV is computed from eyeballed values
|
// DEFAULT_ARTSKY_ANGDIV is computed from eyeballed values
|
||||||
// need to recompute it if we ever change the max horiz amplitude
|
// need to recompute it if we ever change the max horiz amplitude
|
||||||
if (!pth || !(pth->flags & 4))
|
if (!pth || !(pth->flags & PTH_SKYBOX))
|
||||||
skyhoriz *= curskyangmul;
|
skyhoriz *= curskyangmul;
|
||||||
|
|
||||||
bglMatrixMode(GL_MODELVIEW);
|
bglMatrixMode(GL_MODELVIEW);
|
||||||
|
@ -3874,7 +3874,7 @@ static void polymer_drawsky(int16_t tilenum, char palnum, int8_t shade)
|
||||||
pth = texcache_fetch(tilenum,0,0,0);
|
pth = texcache_fetch(tilenum,0,0,0);
|
||||||
drawingskybox = 0;
|
drawingskybox = 0;
|
||||||
|
|
||||||
if (pth && (pth->flags & 4))
|
if (pth && (pth->flags & PTH_SKYBOX))
|
||||||
polymer_drawskybox(tilenum, palnum, shade);
|
polymer_drawskybox(tilenum, palnum, shade);
|
||||||
else
|
else
|
||||||
polymer_drawartsky(tilenum, palnum, shade);
|
polymer_drawartsky(tilenum, palnum, shade);
|
||||||
|
@ -3924,7 +3924,7 @@ static void polymer_drawartsky(int16_t tilenum, char palnum, int8_t shad
|
||||||
|
|
||||||
glcolors[i][0] = glcolors[i][1] = glcolors[i][2] = getshadefactor(shade);
|
glcolors[i][0] = glcolors[i][1] = glcolors[i][2] = getshadefactor(shade);
|
||||||
|
|
||||||
if (pth && (pth->flags & 2))
|
if (pth && (pth->flags & PTH_HIGHTILE))
|
||||||
{
|
{
|
||||||
if (pth->palnum != palnum)
|
if (pth->palnum != palnum)
|
||||||
{
|
{
|
||||||
|
@ -4015,7 +4015,7 @@ static void polymer_drawskybox(int16_t tilenum, char palnum, int8_t shad
|
||||||
|
|
||||||
color[0] = color[1] = color[2] = getshadefactor(shade);
|
color[0] = color[1] = color[2] = getshadefactor(shade);
|
||||||
|
|
||||||
if (pth && (pth->flags & 2))
|
if (pth && (pth->flags & PTH_HIGHTILE))
|
||||||
{
|
{
|
||||||
if (pth->palnum != palnum)
|
if (pth->palnum != palnum)
|
||||||
{
|
{
|
||||||
|
@ -4247,7 +4247,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
||||||
|
|
||||||
// If that palette has a highpalookup, we'll never use tinting. We might use
|
// If that palette has a highpalookup, we'll never use tinting. We might use
|
||||||
// alternate skins if they exist later, though.
|
// alternate skins if they exist later, though.
|
||||||
if (!usinghighpal && !(hictinting[tspr->pal].f&4))
|
if (!usinghighpal && !(hictinting[tspr->pal].f & HICTINT_COLORIZE))
|
||||||
{
|
{
|
||||||
if (!(m->flags&1) || (!(tspr->owner >= MAXSPRITES) && sector[sprite[tspr->owner].sectnum].floorpal!=0))
|
if (!(m->flags&1) || (!(tspr->owner >= MAXSPRITES) && sector[sprite[tspr->owner].sectnum].floorpal!=0))
|
||||||
{
|
{
|
||||||
|
@ -4739,7 +4739,7 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
|
||||||
material->diffusemodulation[2] =
|
material->diffusemodulation[2] =
|
||||||
(GLubyte)(getshadefactor(shade) * 0xFF);
|
(GLubyte)(getshadefactor(shade) * 0xFF);
|
||||||
|
|
||||||
if (pth->flags & 2)
|
if (pth->flags & PTH_HIGHTILE)
|
||||||
{
|
{
|
||||||
if (pth->palnum != pal)
|
if (pth->palnum != pal)
|
||||||
{
|
{
|
||||||
|
@ -4769,7 +4769,7 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
|
||||||
}
|
}
|
||||||
|
|
||||||
// PR_BIT_GLOW_MAP
|
// PR_BIT_GLOW_MAP
|
||||||
if (r_fullbrights && pth->flags & 16)
|
if (r_fullbrights && pth->flags & PTH_HASFULLBRIGHT)
|
||||||
material->glowmap = pth->ofb->glpic;
|
material->glowmap = pth->ofb->glpic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ static inline int32_t gltexmayhavealpha(int32_t dapicnum, int32_t dapalnum)
|
||||||
|
|
||||||
for (pth=texcache.list[j]; pth; pth=pth->next)
|
for (pth=texcache.list[j]; pth; pth=pth->next)
|
||||||
if (pth->picnum == dapicnum && pth->palnum == dapalnum)
|
if (pth->picnum == dapicnum && pth->palnum == dapalnum)
|
||||||
return ((pth->flags&8) != 0);
|
return ((pth->flags&PTH_HASALPHA) != 0);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -264,11 +264,12 @@ void gltexinvalidate(int32_t dapicnum, int32_t dapalnum, int32_t dameth)
|
||||||
pthtyp *pth;
|
pthtyp *pth;
|
||||||
|
|
||||||
for (pth=texcache.list[j]; pth; pth=pth->next)
|
for (pth=texcache.list[j]; pth; pth=pth->next)
|
||||||
if (pth->picnum == dapicnum && pth->palnum == dapalnum && (pth->flags & 1) == ((dameth&4)>>2))
|
if (pth->picnum == dapicnum && pth->palnum == dapalnum &&
|
||||||
|
(pth->flags & PTH_CLAMPED) == TO_PTH_CLAMPED(dameth))
|
||||||
{
|
{
|
||||||
pth->flags |= 128;
|
pth->flags |= PTH_INVALIDATED;
|
||||||
if (pth->flags & 16)
|
if (pth->flags & PTH_HASFULLBRIGHT)
|
||||||
pth->ofb->flags |= 128;
|
pth->ofb->flags |= PTH_INVALIDATED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,9 +287,9 @@ void gltexinvalidatetype(int32_t type)
|
||||||
{
|
{
|
||||||
if (type == INVALIDATE_ALL || (type == INVALIDATE_ART && pth->hicr == NULL))
|
if (type == INVALIDATE_ALL || (type == INVALIDATE_ART && pth->hicr == NULL))
|
||||||
{
|
{
|
||||||
pth->flags |= 128;
|
pth->flags |= PTH_INVALIDATED;
|
||||||
if (pth->flags & 16)
|
if (pth->flags & PTH_HASFULLBRIGHT)
|
||||||
pth->ofb->flags |= 128;
|
pth->ofb->flags |= PTH_INVALIDATED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +332,7 @@ void gltexapplyprops(void)
|
||||||
{
|
{
|
||||||
bind_2d_texture(pth->glpic);
|
bind_2d_texture(pth->glpic);
|
||||||
|
|
||||||
if (r_fullbrights && pth->flags & 16)
|
if (r_fullbrights && pth->flags & PTH_HASFULLBRIGHT)
|
||||||
bind_2d_texture(pth->ofb->glpic);
|
bind_2d_texture(pth->ofb->glpic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -398,7 +399,7 @@ void polymost_glreset()
|
||||||
for (pth=texcache.list[i]; pth;)
|
for (pth=texcache.list[i]; pth;)
|
||||||
{
|
{
|
||||||
next = pth->next;
|
next = pth->next;
|
||||||
if (pth->flags & 16) // fullbright textures
|
if (pth->flags & PTH_HASFULLBRIGHT)
|
||||||
{
|
{
|
||||||
bglDeleteTextures(1,&pth->ofb->glpic);
|
bglDeleteTextures(1,&pth->ofb->glpic);
|
||||||
Bfree(pth->ofb);
|
Bfree(pth->ofb);
|
||||||
|
@ -756,10 +757,10 @@ static void fixtransparency(int32_t dapicnum, coltype *dapic, int32_t daxsiz, in
|
||||||
void uploadtexture(int32_t doalloc, int32_t xsiz, int32_t ysiz, int32_t intexfmt, int32_t texfmt, coltype *pic, int32_t tsizx, int32_t tsizy, int32_t dameth)
|
void uploadtexture(int32_t doalloc, int32_t xsiz, int32_t ysiz, int32_t intexfmt, int32_t texfmt, coltype *pic, int32_t tsizx, int32_t tsizy, int32_t dameth)
|
||||||
{
|
{
|
||||||
int32_t x2, y2, j, js=0;
|
int32_t x2, y2, j, js=0;
|
||||||
const int32_t hi = (dameth&8192)?1:0;
|
const int32_t hi = (dameth & DAMETH_HI) ? 1 : 0;
|
||||||
const int32_t nocompress = (dameth&4096)?1:0;
|
const int32_t nocompress = (dameth & DAMETH_NOCOMPRESS) ? 1 : 0;
|
||||||
|
|
||||||
dameth &= ~(8192|4096);
|
dameth &= ~(DAMETH_HI|DAMETH_NOCOMPRESS);
|
||||||
|
|
||||||
if (gltexmaxsize <= 0)
|
if (gltexmaxsize <= 0)
|
||||||
{
|
{
|
||||||
|
@ -879,7 +880,7 @@ static void texture_setup(int32_t dameth)
|
||||||
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, glanisotropy);
|
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, glanisotropy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dameth&4))
|
if (!(dameth & DAMETH_CLAMPED))
|
||||||
{
|
{
|
||||||
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, !tile_is_sky(dapic) ? GL_REPEAT:
|
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, !tile_is_sky(dapic) ? GL_REPEAT:
|
||||||
(glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP));
|
(glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP));
|
||||||
|
@ -949,7 +950,7 @@ int32_t gloadtile_art(int32_t dapic, int32_t dapal, int32_t dashade, int32_t dam
|
||||||
int32_t dacol;
|
int32_t dacol;
|
||||||
int32_t x2 = (x < tsizx) ? x : x-tsizx;
|
int32_t x2 = (x < tsizx) ? x : x-tsizx;
|
||||||
|
|
||||||
if ((dameth&4) && (x >= tsizx || y >= tsizy)) //Clamp texture
|
if ((dameth & DAMETH_CLAMPED) && (x >= tsizx || y >= tsizy)) //Clamp texture
|
||||||
{
|
{
|
||||||
wpptr->r = wpptr->g = wpptr->b = wpptr->a = 0;
|
wpptr->r = wpptr->g = wpptr->b = wpptr->a = 0;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1009,7 +1010,7 @@ int32_t gloadtile_art(int32_t dapic, int32_t dapal, int32_t dashade, int32_t dam
|
||||||
pth->palnum = dapal;
|
pth->palnum = dapal;
|
||||||
pth->shade = dashade;
|
pth->shade = dashade;
|
||||||
pth->effects = 0;
|
pth->effects = 0;
|
||||||
pth->flags = ((dameth&4)>>2) | (hasalpha<<3);
|
pth->flags = TO_PTH_CLAMPED(dameth) | (hasalpha*PTH_HASALPHA);
|
||||||
pth->hicr = NULL;
|
pth->hicr = NULL;
|
||||||
|
|
||||||
if (hasfullbright && !fullbrightloadingpass)
|
if (hasfullbright && !fullbrightloadingpass)
|
||||||
|
@ -1022,7 +1023,7 @@ int32_t gloadtile_art(int32_t dapic, int32_t dapal, int32_t dashade, int32_t dam
|
||||||
if (!pth->ofb)
|
if (!pth->ofb)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
pth->flags |= (1<<4);
|
pth->flags |= PTH_HASFULLBRIGHT;
|
||||||
|
|
||||||
if (gloadtile_art(dapic, dapal, 0, dameth, pth->ofb, 1))
|
if (gloadtile_art(dapic, dapal, 0, dameth, pth->ofb, 1))
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1087,7 +1088,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
|
||||||
{
|
{
|
||||||
tsizx = cachead.xdim;
|
tsizx = cachead.xdim;
|
||||||
tsizy = cachead.ydim;
|
tsizy = cachead.ydim;
|
||||||
hasalpha = (cachead.flags & 2) ? 0 : 255;
|
hasalpha = (cachead.flags & CACHEAD_HASALPHA) ? 0 : 255;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1181,20 +1182,22 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
|
||||||
tcol.r = cptr[rpptr[x].r];
|
tcol.r = cptr[rpptr[x].r];
|
||||||
tcol.a = rpptr[x].a; hasalpha &= rpptr[x].a;
|
tcol.a = rpptr[x].a; hasalpha &= rpptr[x].a;
|
||||||
|
|
||||||
if (effect & 1)
|
if (effect & HICTINT_GRAYSCALE)
|
||||||
{
|
{
|
||||||
// greyscale
|
// greyscale
|
||||||
tcol.b = max(tcol.b, max(tcol.g, tcol.r));
|
tcol.b = max(tcol.b, max(tcol.g, tcol.r));
|
||||||
tcol.g = tcol.r = tcol.b;
|
tcol.g = tcol.r = tcol.b;
|
||||||
}
|
}
|
||||||
if (effect & 2)
|
|
||||||
|
if (effect & HICTINT_INVERT)
|
||||||
{
|
{
|
||||||
// invert
|
// invert
|
||||||
tcol.b = 255-tcol.b;
|
tcol.b = 255-tcol.b;
|
||||||
tcol.g = 255-tcol.g;
|
tcol.g = 255-tcol.g;
|
||||||
tcol.r = 255-tcol.r;
|
tcol.r = 255-tcol.r;
|
||||||
}
|
}
|
||||||
if (effect & 4)
|
|
||||||
|
if (effect & HICTINT_COLORIZE)
|
||||||
{
|
{
|
||||||
// colorize
|
// colorize
|
||||||
tcol.b = min((int32_t)((tcol.b)*r)/64,255);
|
tcol.b = min((int32_t)((tcol.b)*r)/64,255);
|
||||||
|
@ -1209,7 +1212,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!(dameth&4)) || (facen)) //Duplicate texture pixels (wrapping tricks for non power of 2 texture sizes)
|
if ((!(dameth & DAMETH_CLAMPED)) || facen) //Duplicate texture pixels (wrapping tricks for non power of 2 texture sizes)
|
||||||
{
|
{
|
||||||
if (xsiz > tsizx) //Copy left to right
|
if (xsiz > tsizx) //Copy left to right
|
||||||
{
|
{
|
||||||
|
@ -1233,9 +1236,9 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
|
||||||
Bfree(picfil); picfil = 0;
|
Bfree(picfil); picfil = 0;
|
||||||
|
|
||||||
if (tsizx>>r_downsize <= tilesizx[dapic] || tsizy>>r_downsize <= tilesizy[dapic])
|
if (tsizx>>r_downsize <= tilesizx[dapic] || tsizy>>r_downsize <= tilesizy[dapic])
|
||||||
hicr->flags |= 17;
|
hicr->flags |= (HICR_NOCOMPRESS + HICR_NOSAVE);
|
||||||
|
|
||||||
if (glinfo.texcompr && glusetexcompr && !(hicr->flags & 1))
|
if (glinfo.texcompr && glusetexcompr && !(hicr->flags & HICR_NOSAVE))
|
||||||
intexfmt = (hasalpha == 255) ? GL_COMPRESSED_RGB_ARB : GL_COMPRESSED_RGBA_ARB;
|
intexfmt = (hasalpha == 255) ? GL_COMPRESSED_RGB_ARB : GL_COMPRESSED_RGBA_ARB;
|
||||||
else if (hasalpha == 255) intexfmt = GL_RGB;
|
else if (hasalpha == 255) intexfmt = GL_RGB;
|
||||||
|
|
||||||
|
@ -1244,7 +1247,8 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
|
||||||
bglBindTexture(GL_TEXTURE_2D,pth->glpic);
|
bglBindTexture(GL_TEXTURE_2D,pth->glpic);
|
||||||
|
|
||||||
fixtransparency(-1, pic,tsizx,tsizy,xsiz,ysiz,dameth);
|
fixtransparency(-1, pic,tsizx,tsizy,xsiz,ysiz,dameth);
|
||||||
uploadtexture(doalloc,xsiz,ysiz,intexfmt,texfmt,pic,-1,tsizy,dameth|8192|(hicr->flags & 16?4096:0));
|
uploadtexture(doalloc,xsiz,ysiz,intexfmt,texfmt,pic,-1,tsizy,
|
||||||
|
dameth | DAMETH_HI | (hicr->flags & HICR_NOCOMPRESS ? DAMETH_NOCOMPRESS : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// precalculate scaling parameters for replacement
|
// precalculate scaling parameters for replacement
|
||||||
|
@ -1264,21 +1268,23 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
|
||||||
Bfree(pic); pic=NULL;
|
Bfree(pic); pic=NULL;
|
||||||
|
|
||||||
if (tsizx>>r_downsize <= tilesizx[dapic] || tsizy>>r_downsize <= tilesizy[dapic])
|
if (tsizx>>r_downsize <= tilesizx[dapic] || tsizy>>r_downsize <= tilesizy[dapic])
|
||||||
hicr->flags |= (16+1);
|
hicr->flags |= (HICR_NOCOMPRESS + HICR_NOSAVE);
|
||||||
|
|
||||||
pth->picnum = dapic;
|
pth->picnum = dapic;
|
||||||
pth->effects = effect;
|
pth->effects = effect;
|
||||||
pth->flags = ((dameth&4)>>2) + 2 + ((facen>0)<<2); if (hasalpha != 255) pth->flags |= 8;
|
pth->flags = TO_PTH_CLAMPED(dameth) + PTH_HIGHTILE + (facen>0)*PTH_SKYBOX;
|
||||||
|
if (hasalpha != 255)
|
||||||
|
pth->flags |= PTH_HASALPHA;
|
||||||
pth->skyface = facen;
|
pth->skyface = facen;
|
||||||
pth->hicr = hicr;
|
pth->hicr = hicr;
|
||||||
|
|
||||||
if (glinfo.texcompr && glusetexcompr && glusetexcache && !(hicr->flags & 1))
|
if (glinfo.texcompr && glusetexcompr && glusetexcache && !(hicr->flags & HICR_NOSAVE))
|
||||||
if (!gotcache)
|
if (!gotcache)
|
||||||
{
|
{
|
||||||
int32_t j, x;
|
int32_t j, x;
|
||||||
|
|
||||||
// save off the compressed version
|
// save off the compressed version
|
||||||
if (hicr->flags & 16) cachead.quality = 0;
|
if (hicr->flags & HICR_NOCOMPRESS) cachead.quality = 0;
|
||||||
else cachead.quality = r_downsize;
|
else cachead.quality = r_downsize;
|
||||||
cachead.xdim = tsizx>>cachead.quality;
|
cachead.xdim = tsizx>>cachead.quality;
|
||||||
cachead.ydim = tsizy>>cachead.quality;
|
cachead.ydim = tsizy>>cachead.quality;
|
||||||
|
@ -1289,7 +1295,12 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
|
||||||
if (xsiz == pow2long[j]) { x |= 1; }
|
if (xsiz == pow2long[j]) { x |= 1; }
|
||||||
if (ysiz == pow2long[j]) { x |= 2; }
|
if (ysiz == pow2long[j]) { x |= 2; }
|
||||||
}
|
}
|
||||||
cachead.flags = (x!=3) | (hasalpha != 255 ? 2 : 0) | (hicr->flags&16 ? 8 : 0); // handle nocompress
|
|
||||||
|
// handle nocompress:
|
||||||
|
cachead.flags = (x!=3)*CACHEAD_NONPOW2 |
|
||||||
|
(hasalpha != 255 ? CACHEAD_HASALPHA : 0) |
|
||||||
|
(hicr->flags & HICR_NOCOMPRESS ? 8 : 0);
|
||||||
|
|
||||||
/// OSD_Printf("Caching \"%s\"\n", fn);
|
/// OSD_Printf("Caching \"%s\"\n", fn);
|
||||||
texcache_writetex(fn, picfillen+(dapalnum<<8), dameth, effect, &cachead);
|
texcache_writetex(fn, picfillen+(dapalnum<<8), dameth, effect, &cachead);
|
||||||
|
|
||||||
|
@ -1441,7 +1452,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r_fullbrights && pth->flags & 16)
|
if (r_fullbrights && pth->flags & PTH_HASFULLBRIGHT)
|
||||||
if (indrawroomsandmasks)
|
if (indrawroomsandmasks)
|
||||||
{
|
{
|
||||||
if (!fullbrightdrawingpass)
|
if (!fullbrightdrawingpass)
|
||||||
|
@ -1505,7 +1516,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
|
||||||
if (glowpth && glowpth->hicr && (glowpth->hicr->palnum == GLOWPAL))
|
if (glowpth && glowpth->hicr && (glowpth->hicr->palnum == GLOWPAL))
|
||||||
polymost_setupglowtexture(&texunits, glowpth ? glowpth->glpic : 0);
|
polymost_setupglowtexture(&texunits, glowpth ? glowpth->glpic : 0);
|
||||||
|
|
||||||
if (pth && (pth->flags & 2))
|
if (pth && (pth->flags & PTH_HIGHTILE))
|
||||||
{
|
{
|
||||||
hackscx = pth->scalex;
|
hackscx = pth->scalex;
|
||||||
hackscy = pth->scaley;
|
hackscy = pth->scaley;
|
||||||
|
@ -1589,9 +1600,9 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
|
||||||
|
|
||||||
// tinting happens only to hightile textures, and only if the texture we're
|
// tinting happens only to hightile textures, and only if the texture we're
|
||||||
// rendering isn't for the same palette as what we asked for
|
// rendering isn't for the same palette as what we asked for
|
||||||
if (!(hictinting[globalpal].f&4))
|
if (!(hictinting[globalpal].f & HICTINT_COLORIZE))
|
||||||
{
|
{
|
||||||
if (pth && (pth->flags & 2))
|
if (pth && (pth->flags & PTH_HIGHTILE))
|
||||||
{
|
{
|
||||||
if (pth->palnum != globalpal)
|
if (pth->palnum != globalpal)
|
||||||
{
|
{
|
||||||
|
@ -1608,7 +1619,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// hack: this is for drawing the 8-bit crosshair recolored in polymost
|
// hack: this is for drawing the 8-bit crosshair recolored in polymost
|
||||||
else if (hictinting[globalpal].f & 8)
|
else if (hictinting[globalpal].f & HICTINT_USEONART)
|
||||||
{
|
{
|
||||||
pc[0] *= (float)hictinting[globalpal].r / 255.0;
|
pc[0] *= (float)hictinting[globalpal].r / 255.0;
|
||||||
pc[1] *= (float)hictinting[globalpal].g / 255.0;
|
pc[1] *= (float)hictinting[globalpal].g / 255.0;
|
||||||
|
@ -4866,7 +4877,7 @@ int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, i
|
||||||
else ratio = dimen/scy;
|
else ratio = dimen/scy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pth || (pth->flags & 8))
|
if (!pth || (pth->flags & PTH_HASALPHA))
|
||||||
{
|
{
|
||||||
bglDisable(GL_TEXTURE_2D);
|
bglDisable(GL_TEXTURE_2D);
|
||||||
bglBegin(GL_TRIANGLE_FAN);
|
bglBegin(GL_TRIANGLE_FAN);
|
||||||
|
|
|
@ -58,13 +58,15 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
|
||||||
{
|
{
|
||||||
if (pth->picnum == dapicnum && pth->palnum == si->palnum &&
|
if (pth->picnum == dapicnum && pth->palnum == si->palnum &&
|
||||||
(si->palnum>0 ? 1 : (pth->effects == hictinting[dapalnum].f)) &&
|
(si->palnum>0 ? 1 : (pth->effects == hictinting[dapalnum].f)) &&
|
||||||
(pth->flags & (1+2+4)) == (((dameth&4)>>2)+2+((drawingskybox>0)<<2)) &&
|
(pth->flags & (PTH_CLAMPED + PTH_HIGHTILE + PTH_SKYBOX))
|
||||||
|
== (TO_PTH_CLAMPED(dameth) + PTH_HIGHTILE + (drawingskybox>0)*PTH_SKYBOX) &&
|
||||||
(drawingskybox>0 ? (pth->skyface == drawingskybox) : 1)
|
(drawingskybox>0 ? (pth->skyface == drawingskybox) : 1)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (pth->flags & 128)
|
if (pth->flags & PTH_INVALIDATED)
|
||||||
{
|
{
|
||||||
pth->flags &= ~128;
|
pth->flags &= ~PTH_INVALIDATED;
|
||||||
|
|
||||||
if (gloadtile_hi(dapicnum,dapalnum,drawingskybox,si,dameth,pth,0,
|
if (gloadtile_hi(dapicnum,dapalnum,drawingskybox,si,dameth,pth,0,
|
||||||
(si->palnum>0) ? 0 : hictinting[dapalnum].f)) // reload tile
|
(si->palnum>0) ? 0 : hictinting[dapalnum].f)) // reload tile
|
||||||
{
|
{
|
||||||
|
@ -86,12 +88,13 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
|
||||||
for (i = (GLTEXCACHEADSIZ - 1); i >= 0; i--)
|
for (i = (GLTEXCACHEADSIZ - 1); i >= 0; i--)
|
||||||
for (pth2=texcache.list[i]; pth2; pth2=pth2->next)
|
for (pth2=texcache.list[i]; pth2; pth2=pth2->next)
|
||||||
{
|
{
|
||||||
if ((pth2->hicr) && (pth2->hicr->filename) && (Bstrcasecmp(pth2->hicr->filename, si->filename) == 0))
|
if (pth2->hicr && pth2->hicr->filename && Bstrcasecmp(pth2->hicr->filename, si->filename) == 0)
|
||||||
{
|
{
|
||||||
Bmemcpy(pth, pth2, sizeof(pthtyp));
|
Bmemcpy(pth, pth2, sizeof(pthtyp));
|
||||||
pth->picnum = dapicnum;
|
pth->picnum = dapicnum;
|
||||||
pth->flags = ((dameth&4)>>2) + 2 + ((drawingskybox>0)<<2);
|
pth->flags = TO_PTH_CLAMPED(dameth) + PTH_HIGHTILE + (drawingskybox>0)*PTH_SKYBOX;
|
||||||
if (pth2->flags & 8) pth->flags |= 8; //hasalpha
|
if (pth2->flags & PTH_HASALPHA)
|
||||||
|
pth->flags |= PTH_HASALPHA;
|
||||||
pth->hicr = si;
|
pth->hicr = si;
|
||||||
pth->next = texcache.list[j];
|
pth->next = texcache.list[j];
|
||||||
|
|
||||||
|
@ -119,12 +122,13 @@ tryart:
|
||||||
// load from art
|
// load from art
|
||||||
for (pth=texcache.list[j]; pth; pth=pth->next)
|
for (pth=texcache.list[j]; pth; pth=pth->next)
|
||||||
if (pth->picnum == dapicnum && pth->palnum == dapalnum && pth->shade == dashade &&
|
if (pth->picnum == dapicnum && pth->palnum == dapalnum && pth->shade == dashade &&
|
||||||
(pth->flags & (1+2)) == ((dameth&4)>>2)
|
(pth->flags & (PTH_CLAMPED+PTH_HIGHTILE)) == TO_PTH_CLAMPED(dameth)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (pth->flags & 128)
|
if (pth->flags & PTH_INVALIDATED)
|
||||||
{
|
{
|
||||||
pth->flags &= ~128;
|
pth->flags &= ~PTH_INVALIDATED;
|
||||||
|
|
||||||
if (gloadtile_art(dapicnum,dapalnum,dashade,dameth,pth,0))
|
if (gloadtile_art(dapicnum,dapalnum,dashade,dameth,pth,0))
|
||||||
return NULL; //reload tile (for animations)
|
return NULL; //reload tile (for animations)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// XXX: This program is not in sync with EDuke32 (e.g. texcacheheader type).
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
|
@ -3358,7 +3358,7 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b)
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
// XXX: this makes us also load all hightile textures tinted with the crosshair color!
|
// XXX: this makes us also load all hightile textures tinted with the crosshair color!
|
||||||
Bmemcpy(&hictinting[CROSSHAIR_PAL], &CrosshairColors, sizeof(palette_t));
|
Bmemcpy(&hictinting[CROSSHAIR_PAL], &CrosshairColors, sizeof(palette_t));
|
||||||
hictinting[CROSSHAIR_PAL].f = 9;
|
hictinting[CROSSHAIR_PAL].f = HICTINT_USEONART | HICTINT_GRAYSCALE;
|
||||||
#endif
|
#endif
|
||||||
invalidatetile(CROSSHAIR, -1, -1);
|
invalidatetile(CROSSHAIR, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue