From e379cd3655be029d6ab981d8415867cf57cb2d1b Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 8 Feb 2014 14:37:52 +0000 Subject: [PATCH] Polymer: factor out polymer_invalidatesprite(), use when viewscreen tex changed. Also, rewrite invalidatetile() for clarity. git-svn-id: https://svn.eduke32.com/eduke32@4303 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/polymer.h | 8 +++++ polymer/eduke32/build/src/engine.c | 44 ++++++++++--------------- polymer/eduke32/build/src/polymer.c | 3 +- polymer/eduke32/source/sector.c | 4 +-- 4 files changed, 28 insertions(+), 31 deletions(-) diff --git a/polymer/eduke32/build/include/polymer.h b/polymer/eduke32/build/include/polymer.h index e6ef6ee38..cdec32c50 100644 --- a/polymer/eduke32/build/include/polymer.h +++ b/polymer/eduke32/build/include/polymer.h @@ -332,6 +332,14 @@ void polymer_texinvalidate(void); void polymer_definehighpalookup(char basepalnum, char palnum, char *fn); int32_t polymer_havehighpalookup(int32_t basepalnum, int32_t palnum); +static inline void polymer_invalidatesprite(int32_t i) +{ + extern _prsprite *prsprites[MAXSPRITES]; + + if (prsprites[i]) + prsprites[i]->crc = 0xDEADBEEF; +} + # ifdef POLYMER_C // CORE diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 740da4ec3..2de921499 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -17363,36 +17363,26 @@ void setrollangle(int32_t rolla) // void invalidatetile(int16_t tilenume, int32_t pal, int32_t how) { -#ifdef USE_OPENGL - int32_t numpal, firstpal, np; - int32_t hp; - - if (getrendermode() < REND_POLYMOST) return; - - if (pal < 0) - { - numpal = MAXPALOOKUPS; - firstpal = 0; - } - else - { - numpal = 1; - firstpal = pal % MAXPALOOKUPS; - } - - for (hp = 0; hp < 8; hp+=4) - { - if (!(how & pow2long[hp])) continue; - - for (np = firstpal; np < firstpal+numpal; np++) - { - gltexinvalidate(tilenume, np, hp); - } - } -#endif +#if !defined USE_OPENGL UNREFERENCED_PARAMETER(tilenume); UNREFERENCED_PARAMETER(pal); UNREFERENCED_PARAMETER(how); +#else + if (getrendermode() >= REND_POLYMOST) + { + int32_t hp, np; + + const int32_t firstpal = (pal < 0) ? 0 : pal; + const int32_t numpals = (pal < 0) ? MAXPALOOKUPS : 1; + + for (hp = 0; hp <= 4; hp+=4) + { + if (how & pow2long[hp]) + for (np = firstpal; np < firstpal+numpals; np++) + gltexinvalidate(tilenume, np, hp); + } + } +#endif } diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 9c3f87984..3976b5154 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -1622,8 +1622,7 @@ void polymer_texinvalidate(void) i = 0; while (i < MAXSPRITES) { - if (prsprites[i]) - prsprites[i]->crc = 0xDEADBEEF; + polymer_invalidatesprite(i); i++; } diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index e04b6fdb2..f319a91bf 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -373,9 +373,9 @@ void G_AnimateCamSprite(void) G_SetupCamTile(OW, TILE_VIEWSCR); #ifdef POLYMER - // HACK: force texture update on viewscreen sprite in Polymer! + // Force texture update on viewscreen sprite in Polymer! if (getrendermode() == REND_POLYMER) - sprite[i].filler ^= (1<<1); + polymer_invalidatesprite(i); #endif } }