From 8282a7e8469c4ca3c45240240fead9b5166629e3 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 28 Mar 2015 09:49:11 +0000 Subject: [PATCH] Defs: Add "nocompress" and "nodownsize" tokens to model skin definitions. git-svn-id: https://svn.eduke32.com/eduke32@5107 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 2 +- polymer/eduke32/build/include/mdsprite.h | 2 +- polymer/eduke32/build/src/defs.c | 32 +++++++++++++++++------- polymer/eduke32/build/src/mdsprite.c | 14 ++++++----- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 0e90063d1..af46294dd 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -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); diff --git a/polymer/eduke32/build/include/mdsprite.h b/polymer/eduke32/build/include/mdsprite.h index 355f1b9f7..edb0ba2d7 100644 --- a/polymer/eduke32/build/include/mdsprite.h +++ b/polymer/eduke32/build/include/mdsprite.h @@ -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 diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index 22c866cd0..e7cfb94c5 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -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; diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index 9e4e71fd8..9ebafd51f 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -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);