Split Polymer artmap setup into polymer_setupartmap()

git-svn-id: https://svn.eduke32.com/eduke32@5480 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2015-12-23 04:05:43 +00:00
parent 61059816b8
commit 40a2780eb0

View file

@ -4839,41 +4839,11 @@ static void polymer_getscratchmaterial(_prmaterial* material)
material->mdspritespace = GL_FALSE;
}
static _prbucket* polymer_getbuildmaterial(_prmaterial* material, int16_t tilenum, char pal, int8_t shade, int8_t vis, int32_t cmeth)
static void polymer_setupartmap(int16_t tilenum, char pal)
{
pthtyp* pth;
int32_t usinghighpal = 0;
_prbucket* bucketptr;
// find corresponding bucket; XXX key that with pr_buckets later, need to be tied to restartvid
bucketptr = polymer_findbucket(tilenum, pal);
polymer_getscratchmaterial(material);
if (!waloff[tilenum])
loadtile(tilenum);
// PR_BIT_DIFFUSE_MAP
pth = texcache_fetch(tilenum, pal, 0, cmeth);
if (pth)
{
material->diffusemap = pth->glpic;
if (pth->hicr)
{
material->diffusescale[0] = pth->hicr->scale.x;
material->diffusescale[1] = pth->hicr->scale.y;
}
}
int32_t usinghighpal = 0;
// Lazily fill in all the textures we need, move this to precaching later
if (pr_artmapping && !(globalflags & GLOBAL_NO_GL_TILESHADES) && polymer_eligible_for_artmap(tilenum, pth)) {
if (!prartmaps[tilenum]) {
char *tilebuffer = (char *)waloff[tilenum];
char *tempbuffer = (char *)Xmalloc(tilesiz[tilenum].x * tilesiz[tilenum].y);
char *tilebuffer = (char *) waloff[tilenum];
char *tempbuffer = (char *) Xmalloc(tilesiz[tilenum].x * tilesiz[tilenum].y);
int i, j, k;
i = k = 0;
@ -4920,8 +4890,8 @@ static _prbucket* polymer_getbuildmaterial(_prmaterial* material, int16_t tile
basepaltable[curbasepal]);
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge ? GL_CLAMP_TO_EDGE : GL_CLAMP);
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glinfo.clamptoedge ? GL_CLAMP_TO_EDGE : GL_CLAMP);
bglBindTexture(GL_TEXTURE_2D, 0);
}
@ -4939,10 +4909,43 @@ static _prbucket* polymer_getbuildmaterial(_prmaterial* material, int16_t tile
palookup[pal]);
bglTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
bglTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
bglTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
bglTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
bglTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, glinfo.clamptoedge ? GL_CLAMP_TO_EDGE : GL_CLAMP);
bglTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, glinfo.clamptoedge ? GL_CLAMP_TO_EDGE : GL_CLAMP);
bglBindTexture(GL_TEXTURE_RECTANGLE, 0);
}
}
static _prbucket* polymer_getbuildmaterial(_prmaterial* material, int16_t tilenum, char pal, int8_t shade, int8_t vis, int32_t cmeth)
{
// find corresponding bucket; XXX key that with pr_buckets later, need to be tied to restartvid
_prbucket *bucketptr = polymer_findbucket(tilenum, pal);
polymer_getscratchmaterial(material);
if (!waloff[tilenum])
loadtile(tilenum);
// PR_BIT_DIFFUSE_MAP
pthtyp *pth = texcache_fetch(tilenum, pal, 0, cmeth);
if (pth)
{
material->diffusemap = pth->glpic;
if (pth->hicr)
{
material->diffusescale[0] = pth->hicr->scale.x;
material->diffusescale[1] = pth->hicr->scale.y;
}
}
int32_t usinghighpal = 0;
// Lazily fill in all the textures we need, move this to precaching later
if (pr_artmapping && !(globalflags & GLOBAL_NO_GL_TILESHADES) && polymer_eligible_for_artmap(tilenum, pth))
{
if (!prartmaps[tilenum] || !prbasepalmaps[curbasepal] || !prlookups[pal])
polymer_setupartmap(tilenum, pal);
material->artmap = prartmaps[tilenum];
material->basepalmap = prbasepalmaps[curbasepal];
@ -4953,7 +4956,7 @@ static _prbucket* polymer_getbuildmaterial(_prmaterial* material, int16_t tile
}
material->shadeoffset = shade;
material->visibility = ((uint8_t)(vis+16) / 16.0f);
material->visibility = ((uint8_t) (vis+16) / 16.0f);
// all the stuff below is mutually exclusive with artmapping
goto done;