From 75801f2e68ff775aba7f623137202a4d3d2bc4f9 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 28 Mar 2015 09:49:37 +0000 Subject: [PATCH] Defs: Add token "forcefilter" to textures, skyboxes, and model skins. It forces the use of GL filtering for the resource in question. git-svn-id: https://svn.eduke32.com/eduke32@5108 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 6 ++++++ polymer/eduke32/build/include/hightile.h | 1 + polymer/eduke32/build/include/polymost.h | 1 + polymer/eduke32/build/src/defs.c | 13 ++++++++++++ polymer/eduke32/build/src/mdsprite.c | 6 ++++-- polymer/eduke32/build/src/polymost.c | 26 ++++++++---------------- polymer/eduke32/source/menus.c | 2 +- 7 files changed, 35 insertions(+), 20 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index af46294dd..d57119ba7 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -1260,6 +1260,12 @@ void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype); extern int32_t glanisotropy; extern int32_t glusetexcompr; extern int32_t gltexfiltermode; + +enum { + TEXFILTER_OFF = 2, // GL_NEAREST_MIPMAP_NEAREST + TEXFILTER_ON = 5, // GL_LINEAR_MIPMAP_LINEAR +}; + extern int32_t glredbluemode; extern int32_t glusetexcache, glusememcache; extern int32_t glmultisample, glnvmultisamplehint; diff --git a/polymer/eduke32/build/include/hightile.h b/polymer/eduke32/build/include/hightile.h index 6c0494986..65482754b 100644 --- a/polymer/eduke32/build/include/hightile.h +++ b/polymer/eduke32/build/include/hightile.h @@ -75,6 +75,7 @@ enum enum { HICR_NOSAVE = 1, + HICR_FORCEFILTER = 2, HICR_NOCOMPRESS = 16, }; diff --git a/polymer/eduke32/build/include/polymost.h b/polymer/eduke32/build/include/polymost.h index 675cd3c6c..b100989f5 100644 --- a/polymer/eduke32/build/include/polymost.h +++ b/polymer/eduke32/build/include/polymost.h @@ -166,6 +166,7 @@ enum { PTH_HASALPHA = 8, PTH_HASFULLBRIGHT = 16, PTH_NPOTWALL = DAMETH_WALL, // r_npotwallmode=1 generated texture + PTH_FORCEFILTER = 64, PTH_INVALIDATED = 128, }; diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index e7cfb94c5..22bc29d22 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -76,6 +76,7 @@ enum scripttoken_t T_NOFLOORPAL, T_RED,T_GREEN,T_BLUE, T_TEXTURE,T_ALPHACUT,T_XSCALE,T_YSCALE,T_SPECPOWER,T_SPECFACTOR,T_NOCOMPRESS,T_NODOWNSIZE, + T_FORCEFILTER, T_ORIGSIZEX,T_ORIGSIZEY, T_UNDEFMODEL,T_UNDEFMODELRANGE,T_UNDEFMODELOF,T_UNDEFTEXTURE,T_UNDEFTEXTURERANGE, T_ALPHAHACK,T_ALPHAHACKRANGE, @@ -1212,6 +1213,7 @@ static int32_t defsparser(scriptfile *script) { "specfactor", T_SPECFACTOR }, { "specularfactor", T_SPECFACTOR }, { "parallaxbias", T_SPECFACTOR }, { "nocompress", T_NOCOMPRESS }, { "nodownsize", T_NODOWNSIZE }, + { "forcefilter", T_FORCEFILTER }, }; if (scriptfile_getbraces(script,&skinend)) break; @@ -1236,6 +1238,8 @@ static int32_t defsparser(scriptfile *script) flags |= HICR_NOSAVE; break; case T_NODOWNSIZE: flags |= HICR_NOCOMPRESS; break; + case T_FORCEFILTER: + flags |= HICR_FORCEFILTER; break; #endif } } @@ -1540,6 +1544,7 @@ static int32_t defsparser(scriptfile *script) { "dn" ,T_BOTTOM },{ "bottom" ,T_BOTTOM },{ "floor" ,T_BOTTOM },{ "down" ,T_BOTTOM }, { "nocompress", T_NOCOMPRESS }, { "nodownsize", T_NODOWNSIZE }, + { "forcefilter", T_FORCEFILTER }, }; if (scriptfile_getbraces(script,&modelend)) break; @@ -1569,6 +1574,8 @@ static int32_t defsparser(scriptfile *script) flags |= HICR_NOSAVE; break; case T_NODOWNSIZE: flags |= HICR_NOCOMPRESS; break; + case T_FORCEFILTER: + flags |= HICR_FORCEFILTER; break; #endif } } @@ -1878,6 +1885,7 @@ static int32_t defsparser(scriptfile *script) { "specfactor", T_SPECFACTOR }, { "specularfactor", T_SPECFACTOR }, { "parallaxbias", T_SPECFACTOR }, { "nocompress", T_NOCOMPRESS }, { "nodownsize", T_NODOWNSIZE }, + { "forcefilter", T_FORCEFILTER }, { "orig_sizex", T_ORIGSIZEX }, { "orig_sizey", T_ORIGSIZEY } }; @@ -1904,6 +1912,8 @@ static int32_t defsparser(scriptfile *script) flags |= HICR_NOSAVE; break; case T_NODOWNSIZE: flags |= HICR_NOCOMPRESS; break; + case T_FORCEFILTER: + flags |= HICR_FORCEFILTER; break; #endif case T_ORIGSIZEX: scriptfile_getnumber(script, &xsiz); @@ -1967,6 +1977,7 @@ static int32_t defsparser(scriptfile *script) { "specfactor", T_SPECFACTOR }, { "specularfactor", T_SPECFACTOR }, { "parallaxbias", T_SPECFACTOR }, { "nocompress", T_NOCOMPRESS }, { "nodownsize", T_NODOWNSIZE }, + { "forcefilter", T_FORCEFILTER }, }; if (EDUKE32_PREDICT_FALSE(scriptfile_getbraces(script,&detailend))) break; @@ -1989,6 +2000,8 @@ static int32_t defsparser(scriptfile *script) flags |= HICR_NOSAVE; break; case T_NODOWNSIZE: flags |= HICR_NOCOMPRESS; break; + case T_FORCEFILTER: + flags |= HICR_FORCEFILTER; break; #endif default: break; diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index 9ebafd51f..12d4f963e 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -879,8 +879,10 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf) m->skinloaded = 1+number; } - bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,glfiltermodes[gltexfiltermode].mag); - bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,glfiltermodes[gltexfiltermode].min); + int32_t const filter = sk->flags & HICR_FORCEFILTER ? TEXFILTER_ON : gltexfiltermode; + + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,glfiltermodes[filter].mag); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,glfiltermodes[filter].min); #ifndef EDUKE32_GLES if (glinfo.maxanisotropy > 1.0) bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAX_ANISOTROPY_EXT,glanisotropy); diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index aa69be7d4..0db820965 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -92,7 +92,7 @@ struct glfiltermodes glfiltermodes[NUMGLFILTERMODES] = }; int32_t glanisotropy = 1; // 0 = maximum supported by card -int32_t gltexfiltermode = 2; // GL_NEAREST_MIPMAP_NEAREST +int32_t gltexfiltermode = TEXFILTER_OFF; #ifdef EDUKE32_GLES int32_t glusetexcompr = 0; @@ -241,17 +241,12 @@ void gltexapplyprops(void) { for (pthtyp *pth=texcache.list[i]; pth; pth=pth->next) { -#ifndef EDUKE32_TOUCH_DEVICES - bind_2d_texture(pth->glpic, -1); + int32_t const filter = pth->flags & PTH_FORCEFILTER ? TEXFILTER_ON : -1; + + bind_2d_texture(pth->glpic, filter); if (r_fullbrights && pth->flags & PTH_HASFULLBRIGHT) - bind_2d_texture(pth->ofb->glpic, -1); -#else - bind_2d_texture(pth->glpic, pth->flags & PTH_HIGHTILE ? 5 : -1); - - if (r_fullbrights && pth->flags & PTH_HASFULLBRIGHT) - bind_2d_texture(pth->ofb->glpic, pth->flags & PTH_HIGHTILE ? 5 : -1); -#endif + bind_2d_texture(pth->ofb->glpic, filter); } } @@ -274,7 +269,7 @@ void gltexapplyprops(void) { if (!sk->texid[j]) continue; - bind_2d_texture(sk->texid[j], -1); + bind_2d_texture(sk->texid[j], sk->flags & HICR_FORCEFILTER ? TEXFILTER_ON : -1); } } } @@ -1171,11 +1166,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp pth->scale.y = (float)tsiz.y / (float)tilesiz[dapic].y; } -#ifdef EDUKE32_TOUCH_DEVICES - polymost_setuptexture(dameth, 5); -#else - polymost_setuptexture(dameth, -1); -#endif + polymost_setuptexture(dameth, hicr->flags & HICR_FORCEFILTER ? TEXFILTER_ON : -1); DO_FREE_AND_NULL(pic); @@ -1184,7 +1175,8 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp pth->picnum = dapic; pth->effects = effect; - pth->flags = TO_PTH_CLAMPED(dameth) | PTH_HIGHTILE | ((facen>0) * PTH_SKYBOX) | ((hasalpha != 255) ? PTH_HASALPHA : 0); + pth->flags = TO_PTH_CLAMPED(dameth) | PTH_HIGHTILE | ((facen>0) * PTH_SKYBOX) | ((hasalpha != 255) ? PTH_HASALPHA : 0) | + (hicr->flags & HICR_FORCEFILTER ? PTH_FORCEFILTER : 0); pth->skyface = facen; pth->hicr = hicr; diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 9c7722a64..b76673049 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -2660,7 +2660,7 @@ static int32_t M_MenuEntryOptionModify(MenuEntry_t *entry, int32_t newOption) #ifdef USE_OPENGL else if (entry == &ME_DISPLAYSETUP_TEXFILTER) { - gltexfiltermode = newOption ? 5 : 2; + gltexfiltermode = newOption ? TEXFILTER_ON : TEXFILTER_OFF; gltexapplyprops(); } else if (entry == &ME_DISPLAYSETUP_ASPECTRATIO)