mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 11:10:39 +00:00
Avoid loading textures two times.
git-svn-id: https://svn.eduke32.com/eduke32@499 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b48a0a933b
commit
39c818d053
4 changed files with 41 additions and 11 deletions
|
@ -1205,7 +1205,7 @@ static int defsparser(scriptfile *script)
|
||||||
break;
|
break;
|
||||||
} else kclose(i);
|
} else kclose(i);
|
||||||
|
|
||||||
hicsetsubsttex(tile,DETAILPAL,fn,detailscale,flags);
|
hicsetsubsttex(tile,DETAILPAL,fn,(1.0f / detailscale),flags);
|
||||||
} break;
|
} break;
|
||||||
case T_GLOW: {
|
case T_GLOW: {
|
||||||
char *glowtokptr = script->ltextptr, *glowend;
|
char *glowtokptr = script->ltextptr, *glowend;
|
||||||
|
|
|
@ -46,7 +46,7 @@ static hicreplctyp * hicfindsubst(long picnum, long palnum, long skybox)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!palnum || palnum == DETAILPAL) break;
|
if (!palnum || palnum >= (MAXPALOOKUPS - RESERVEDPALS)) break;
|
||||||
palnum = 0;
|
palnum = 0;
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
|
@ -145,7 +145,10 @@ int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, char f
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
hrn->ignore = 0;
|
hrn->ignore = 0;
|
||||||
hrn->alphacut = min(alphacut,1.0);
|
if (palnum < (MAXPALOOKUPS - RESERVEDPALS))
|
||||||
|
hrn->alphacut = min(alphacut,1.0);
|
||||||
|
else
|
||||||
|
hrn->alphacut = alphacut;
|
||||||
hrn->flags = flags;
|
hrn->flags = flags;
|
||||||
if (hr == NULL) {
|
if (hr == NULL) {
|
||||||
hrn->next = hicreplc[picnum];
|
hrn->next = hicreplc[picnum];
|
||||||
|
|
|
@ -661,7 +661,7 @@ failure:
|
||||||
// --------------------------------------------------- JONOF'S COMPRESSED TEXTURE CACHE STUFF
|
// --------------------------------------------------- JONOF'S COMPRESSED TEXTURE CACHE STUFF
|
||||||
|
|
||||||
//Note: even though it says md2model, it works for both md2model&md3model
|
//Note: even though it says md2model, it works for both md2model&md3model
|
||||||
static long mdloadskin (md2model *m, int number, int pal, int surf, int exact)
|
static long mdloadskin (md2model *m, int number, int pal, int surf)
|
||||||
{
|
{
|
||||||
long i,j, fptr=0, bpl, xsiz=0, ysiz=0, osizx, osizy, texfmt = GL_RGBA, intexfmt = GL_RGBA;
|
long i,j, fptr=0, bpl, xsiz=0, ysiz=0, osizx, osizy, texfmt = GL_RGBA, intexfmt = GL_RGBA;
|
||||||
char *skinfile, hasalpha, fn[BMAX_PATH+65];
|
char *skinfile, hasalpha, fn[BMAX_PATH+65];
|
||||||
|
@ -696,7 +696,7 @@ static long mdloadskin (md2model *m, int number, int pal, int surf, int exact)
|
||||||
}
|
}
|
||||||
if (!sk)
|
if (!sk)
|
||||||
{
|
{
|
||||||
if (exact)
|
if (pal >= (MAXPALOOKUPS - RESERVEDPALS))
|
||||||
return (0);
|
return (0);
|
||||||
if (skzero)
|
if (skzero)
|
||||||
{
|
{
|
||||||
|
@ -717,6 +717,17 @@ static long mdloadskin (md2model *m, int number, int pal, int surf, int exact)
|
||||||
if (!skinfile[0]) return 0;
|
if (!skinfile[0]) return 0;
|
||||||
|
|
||||||
if (*texidx) return *texidx;
|
if (*texidx) return *texidx;
|
||||||
|
|
||||||
|
// possibly fetch an already loaded multitexture :_)
|
||||||
|
if (pal >= (MAXPALOOKUPS - RESERVEDPALS))
|
||||||
|
for (i=0;i<nextmodelid;i++)
|
||||||
|
for (skzero = ((md2model *)models[i])->skinmap; skzero; skzero = skzero->next)
|
||||||
|
if (!Bstrcasecmp(skzero->fn, sk->fn) && skzero->texid[hictinting[pal].f])
|
||||||
|
{
|
||||||
|
sk->texid[hictinting[pal].f] = skzero->texid[hictinting[pal].f];
|
||||||
|
return sk->texid[hictinting[pal].f];
|
||||||
|
}
|
||||||
|
|
||||||
*texidx = 0;
|
*texidx = 0;
|
||||||
|
|
||||||
if ((filh = kopen4load(fn, 0)) < 0) {
|
if ((filh = kopen4load(fn, 0)) < 0) {
|
||||||
|
@ -1488,12 +1499,12 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; }
|
||||||
mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f; bglLoadMatrixf(mat);
|
mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f; bglLoadMatrixf(mat);
|
||||||
// PLAG: End
|
// PLAG: End
|
||||||
|
|
||||||
i = mdloadskin((md2model *)m,tile2model[tspr->picnum].skinnum,globalpal,surfi,0); if (!i) continue;
|
i = mdloadskin((md2model *)m,tile2model[tspr->picnum].skinnum,globalpal,surfi); if (!i) continue;
|
||||||
//i = mdloadskin((md2model *)m,tile2model[tspr->picnum].skinnum,surfi); //hack for testing multiple surfaces per MD3
|
//i = mdloadskin((md2model *)m,tile2model[tspr->picnum].skinnum,surfi); //hack for testing multiple surfaces per MD3
|
||||||
bglBindTexture(GL_TEXTURE_2D, i);
|
bglBindTexture(GL_TEXTURE_2D, i);
|
||||||
|
|
||||||
/*if (r_detailmapping && !r_depthpeeling && indrawroomsandmasks)
|
/*if (r_detailmapping && !r_depthpeeling && indrawroomsandmasks)
|
||||||
i = mdloadskin((md2model *)m,tile2model[tspr->picnum].skinnum,DETAILPAL,surfi,1);
|
i = mdloadskin((md2model *)m,tile2model[tspr->picnum].skinnum,DETAILPAL,surfi);
|
||||||
else
|
else
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
|
@ -1532,7 +1543,7 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; }
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (r_glowmapping && !r_depthpeeling && indrawroomsandmasks)
|
if (r_glowmapping && !r_depthpeeling && indrawroomsandmasks)
|
||||||
i = mdloadskin((md2model *)m,tile2model[tspr->picnum].skinnum,GLOWPAL,surfi,1);
|
i = mdloadskin((md2model *)m,tile2model[tspr->picnum].skinnum,GLOWPAL,surfi);
|
||||||
else
|
else
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
|
|
|
@ -357,7 +357,7 @@ pthtyp * gltexcache (long dapicnum, long dapalnum, long dameth)
|
||||||
{
|
{
|
||||||
long i, j;
|
long i, j;
|
||||||
hicreplctyp *si;
|
hicreplctyp *si;
|
||||||
pthtyp *pth;
|
pthtyp *pth, *pth2;
|
||||||
|
|
||||||
j = (dapicnum&(GLTEXCACHEADSIZ-1));
|
j = (dapicnum&(GLTEXCACHEADSIZ-1));
|
||||||
|
|
||||||
|
@ -396,9 +396,25 @@ pthtyp * gltexcache (long dapicnum, long dapalnum, long dameth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pth = (pthtyp *)calloc(1,sizeof(pthtyp));
|
pth = (pthtyp *)calloc(1,sizeof(pthtyp));
|
||||||
if (!pth) return NULL;
|
if (!pth) return NULL;
|
||||||
|
|
||||||
|
// possibly fetch an already loaded multitexture :_)
|
||||||
|
if (dapalnum >= (MAXPALOOKUPS - RESERVEDPALS))
|
||||||
|
for (i = (GLTEXCACHEADSIZ - 1); i >= 0; i--)
|
||||||
|
for (pth2=gltexcachead[i]; pth2; pth2=pth2->next) {
|
||||||
|
if ((pth2->hicr) && (pth2->hicr->filename) && (Bstrcasecmp(pth2->hicr->filename, si->filename) == 0))
|
||||||
|
{
|
||||||
|
memcpy(pth, pth2, sizeof(pthtyp));
|
||||||
|
pth->picnum = dapicnum;
|
||||||
|
pth->hicr = si;
|
||||||
|
pth->next = gltexcachead[j];
|
||||||
|
gltexcachead[j] = pth;
|
||||||
|
return(pth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (gloadtile_hi(dapicnum,drawingskybox,si,dameth,pth,1, (si->palnum>0) ? 0 : hictinting[dapalnum].f)) {
|
if (gloadtile_hi(dapicnum,drawingskybox,si,dameth,pth,1, (si->palnum>0) ? 0 : hictinting[dapalnum].f)) {
|
||||||
free(pth);
|
free(pth);
|
||||||
if (drawingskybox) return NULL;
|
if (drawingskybox) return NULL;
|
||||||
|
@ -1664,7 +1680,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method)
|
||||||
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
|
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
|
||||||
|
|
||||||
|
|
||||||
f = detailpth ? (1.0f / detailpth->hicr->alphacut) : 1.0;
|
f = detailpth ? detailpth->hicr->alphacut : 1.0;
|
||||||
|
|
||||||
bglMatrixMode(GL_TEXTURE);
|
bglMatrixMode(GL_TEXTURE);
|
||||||
bglLoadIdentity();
|
bglLoadIdentity();
|
||||||
|
@ -5424,7 +5440,7 @@ void polymost_precache(long dapicnum, long dapalnum, long datype)
|
||||||
j = ((md3model *)models[mid])->head.numsurfs;
|
j = ((md3model *)models[mid])->head.numsurfs;
|
||||||
|
|
||||||
for (i=0;i<=j;i++)
|
for (i=0;i<=j;i++)
|
||||||
mdloadskin((md2model*)models[mid], 0, dapalnum, i, 0);
|
mdloadskin((md2model*)models[mid], 0, dapalnum, i);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue