Defs: Add "nocompress" and "nodownsize" tokens to model skin definitions.

git-svn-id: https://svn.eduke32.com/eduke32@5107 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-03-28 09:49:11 +00:00
parent 806bbe6d71
commit 8282a7e846
4 changed files with 33 additions and 17 deletions

View file

@ -1345,7 +1345,7 @@ int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume,
int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *frameend,
int32_t fps, int32_t flags);
int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum,
int32_t surfnum, float param, float specpower, float specfactor);
int32_t surfnum, float param, float specpower, float specfactor, int32_t flags);
int32_t md_definehud (int32_t modelid, int32_t tilex, vec3f_t add,
int32_t angadd, int32_t flags, int32_t fov);
int32_t md_undefinetile(int32_t tile);

View file

@ -41,7 +41,7 @@ typedef struct _mdanim_t
typedef struct _mdskinmap_t
{
uint8_t palette, filler[3]; // Build palette number
uint8_t palette, flags, filler[2]; // Build palette number, flags the same as hicreplctyp
int32_t skinnum, surfnum; // Skin identifier, surface number
char *fn; // Skin filename
GLuint texid[HICEFFECTMASK+1]; // OpenGL texture numbers for effect variations

View file

@ -16,6 +16,10 @@
#include "common.h"
#include "mdsprite.h" // md3model_t
#ifdef USE_OPENGL
# include "hightile.h"
#endif
enum scripttoken_t
{
T_INCLUDE = 0,
@ -897,7 +901,7 @@ static int32_t defsparser(scriptfile *script)
break;
#ifdef USE_OPENGL
switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), 0, 0.0f, 1.0f, 1.0f))
switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), 0, 0.0f, 1.0f, 1.0f, 0))
{
case 0:
break;
@ -1191,6 +1195,9 @@ static int32_t defsparser(scriptfile *script)
char *skinend, *skinfn = 0;
int32_t palnum = 0, surfnum = 0;
double param = 1.0, specpower = 1.0, specfactor = 1.0;
#ifdef USE_OPENGL
int32_t flags = 0;
#endif
static const tokenlist modelskintokens[] =
{
@ -1203,7 +1210,8 @@ static int32_t defsparser(scriptfile *script)
{ "detailscale", T_PARAM },
{ "specpower", T_SPECPOWER }, { "specularpower", T_SPECPOWER }, { "parallaxscale", T_SPECPOWER },
{ "specfactor", T_SPECFACTOR }, { "specularfactor", T_SPECFACTOR }, { "parallaxbias", T_SPECFACTOR },
{ "nocompress", T_NOCOMPRESS },
{ "nodownsize", T_NODOWNSIZE },
};
if (scriptfile_getbraces(script,&skinend)) break;
@ -1223,6 +1231,12 @@ static int32_t defsparser(scriptfile *script)
scriptfile_getstring(script,&skinfn); break; //skin filename
case T_SURF:
scriptfile_getnumber(script,&surfnum); break;
#ifdef USE_OPENGL
case T_NOCOMPRESS:
flags |= HICR_NOSAVE; break;
case T_NODOWNSIZE:
flags |= HICR_NOCOMPRESS; break;
#endif
}
}
@ -1257,7 +1271,7 @@ static int32_t defsparser(scriptfile *script)
break;
#ifdef USE_OPENGL
switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), surfnum, param, specpower, specfactor))
switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), surfnum, param, specpower, specfactor, flags))
{
case 0:
break;
@ -1552,9 +1566,9 @@ static int32_t defsparser(scriptfile *script)
scriptfile_getstring(script,&fn[5]); break;
#ifdef USE_OPENGL
case T_NOCOMPRESS:
flags |= 1; break;
flags |= HICR_NOSAVE; break;
case T_NODOWNSIZE:
flags |= 16; break;
flags |= HICR_NOCOMPRESS; break;
#endif
}
}
@ -1887,9 +1901,9 @@ static int32_t defsparser(scriptfile *script)
scriptfile_getdouble(script,&specfactor); break;
#ifdef USE_OPENGL
case T_NOCOMPRESS:
flags |= 1; break;
flags |= HICR_NOSAVE; break;
case T_NODOWNSIZE:
flags |= 16; break;
flags |= HICR_NOCOMPRESS; break;
#endif
case T_ORIGSIZEX:
scriptfile_getnumber(script, &xsiz);
@ -1972,9 +1986,9 @@ static int32_t defsparser(scriptfile *script)
scriptfile_getdouble(script,&specfactor); break;
#ifdef USE_OPENGL
case T_NOCOMPRESS:
flags |= 1; break;
flags |= HICR_NOSAVE; break;
case T_NODOWNSIZE:
flags |= 16; break;
flags |= HICR_NOCOMPRESS; break;
#endif
default:
break;

View file

@ -486,7 +486,7 @@ int32_t md_thinoutmodel(int32_t modelid, uint8_t *usedframebitmap)
}
#endif
int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum, int32_t surfnum, float param, float specpower, float specfactor)
int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum, int32_t surfnum, float param, float specpower, float specfactor, int32_t flags)
{
mdskinmap_t *sk, *skl;
md2model_t *m;
@ -515,6 +515,7 @@ int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32
else if (sk->fn) Bfree(sk->fn);
sk->palette = (uint8_t)palnum;
sk->flags = (uint8_t)flags;
sk->skinnum = skinnum;
sk->surfnum = surfnum;
sk->param = param;
@ -830,7 +831,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
bglBindTexture(GL_TEXTURE_2D, *texidx);
//gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,xsiz,ysiz,GL_BGRA_EXT,GL_UNSIGNED_BYTE,(char *)fptr);
if (glinfo.texcompr && glusetexcompr)
if (glinfo.texcompr && glusetexcompr && !(sk->flags & HICR_NOSAVE))
intexfmt = hasalpha ? GL_COMPRESSED_RGBA_ARB : GL_COMPRESSED_RGB_ARB;
else if (!hasalpha)
intexfmt = GL_RGB;
@ -838,7 +839,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
if (glinfo.bgra)
texfmt = GL_BGRA;
uploadtexture((doalloc&1), siz, intexfmt, texfmt, (coltype *)fptr, siz, DAMETH_HI);
uploadtexture((doalloc&1), siz, intexfmt, texfmt, (coltype *)fptr, siz, DAMETH_HI | (sk->flags & HICR_NOCOMPRESS ? DAMETH_NOCOMPRESS : 0));
Bfree((void *)fptr);
}
@ -888,16 +889,17 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
if (glinfo.texcompr && glusetexcompr && glusetexcache)
if (!gotcache)
if (!gotcache && !(sk->flags & HICR_NOSAVE))
{
const int32_t nonpow2 = check_nonpow2(siz.x) || check_nonpow2(siz.y);
// save off the compressed version
cachead.quality = r_downsize;
cachead.quality = (sk->flags & HICR_NOCOMPRESS) ? 0 : r_downsize;
cachead.xdim = osizx>>cachead.quality;
cachead.ydim = osizy>>cachead.quality;
cachead.flags = nonpow2*CACHEAD_NONPOW2 | (hasalpha ? CACHEAD_HASALPHA : 0);
cachead.flags = nonpow2*CACHEAD_NONPOW2 | (hasalpha ? CACHEAD_HASALPHA : 0) |
(sk->flags & HICR_NOCOMPRESS ? CACHEAD_NOCOMPRESS : 0);
/// OSD_Printf("Caching \"%s\"\n",fn);
texcache_writetex(fn, picfillen, pal<<8, hicfxmask(pal), &cachead);