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 md_defineanimation(int32_t modelid, const char *framestart, const char *frameend,
int32_t fps, int32_t flags); int32_t fps, int32_t flags);
int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum, 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 md_definehud (int32_t modelid, int32_t tilex, vec3f_t add,
int32_t angadd, int32_t flags, int32_t fov); int32_t angadd, int32_t flags, int32_t fov);
int32_t md_undefinetile(int32_t tile); int32_t md_undefinetile(int32_t tile);

View file

@ -41,7 +41,7 @@ typedef struct _mdanim_t
typedef struct _mdskinmap_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 int32_t skinnum, surfnum; // Skin identifier, surface number
char *fn; // Skin filename char *fn; // Skin filename
GLuint texid[HICEFFECTMASK+1]; // OpenGL texture numbers for effect variations GLuint texid[HICEFFECTMASK+1]; // OpenGL texture numbers for effect variations

View file

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

View file

@ -486,7 +486,7 @@ int32_t md_thinoutmodel(int32_t modelid, uint8_t *usedframebitmap)
} }
#endif #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; mdskinmap_t *sk, *skl;
md2model_t *m; 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); else if (sk->fn) Bfree(sk->fn);
sk->palette = (uint8_t)palnum; sk->palette = (uint8_t)palnum;
sk->flags = (uint8_t)flags;
sk->skinnum = skinnum; sk->skinnum = skinnum;
sk->surfnum = surfnum; sk->surfnum = surfnum;
sk->param = param; 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); bglBindTexture(GL_TEXTURE_2D, *texidx);
//gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,xsiz,ysiz,GL_BGRA_EXT,GL_UNSIGNED_BYTE,(char *)fptr); //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; intexfmt = hasalpha ? GL_COMPRESSED_RGBA_ARB : GL_COMPRESSED_RGB_ARB;
else if (!hasalpha) else if (!hasalpha)
intexfmt = GL_RGB; 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) if (glinfo.bgra)
texfmt = GL_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); 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); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
if (glinfo.texcompr && glusetexcompr && glusetexcache) 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); const int32_t nonpow2 = check_nonpow2(siz.x) || check_nonpow2(siz.y);
// save off the compressed version // save off the compressed version
cachead.quality = r_downsize; cachead.quality = (sk->flags & HICR_NOCOMPRESS) ? 0 : r_downsize;
cachead.xdim = osizx>>cachead.quality; cachead.xdim = osizx>>cachead.quality;
cachead.ydim = osizy>>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); /// OSD_Printf("Caching \"%s\"\n",fn);
texcache_writetex(fn, picfillen, pal<<8, hicfxmask(pal), &cachead); texcache_writetex(fn, picfillen, pal<<8, hicfxmask(pal), &cachead);