From 72d8e98eb98125e65100f80188a9106f6d111bdc Mon Sep 17 00:00:00 2001 From: havoc Date: Fri, 24 Jun 2011 01:38:21 +0000 Subject: [PATCH] fixed gfx/menuplyr handling - Draw_NewPic now flags the cachepic_t with CACHEPICFLAG_NEWPIC which disables texflags comparisons git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11213 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=8b0fbc64175362acf3ea872029a423012b76a4f8 --- draw.h | 5 ++++- gl_draw.c | 13 +++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/draw.h b/draw.h index 2019e86c..2a5681a9 100644 --- a/draw.h +++ b/draw.h @@ -39,6 +39,8 @@ typedef struct cachepic_s rtexture_t *tex; // used for hash lookups struct cachepic_s *chain; + // flags - CACHEPICFLAG_NEWPIC for example + unsigned int flags; // has alpha? qboolean hasalpha; // name of pic @@ -51,7 +53,8 @@ typedef enum cachepicflags_e CACHEPICFLAG_NOTPERSISTENT = 1, CACHEPICFLAG_QUIET = 2, CACHEPICFLAG_NOCOMPRESSION = 4, - CACHEPICFLAG_NOCLAMP = 8 + CACHEPICFLAG_NOCLAMP = 8, + CACHEPICFLAG_NEWPIC = 16 // disables matching texflags check, because a pic created with Draw_NewPic should not be subject to that } cachepicflags_t; diff --git a/gl_draw.c b/gl_draw.c index 01329fcb..ef1fee21 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -334,8 +334,13 @@ cachepic_t *Draw_CachePic_Flags(const char *path, unsigned int cachepicflags) crc = CRC_Block((unsigned char *)path, strlen(path)); hashkey = ((crc >> 8) ^ crc) % CACHEPICHASHSIZE; for (pic = cachepichash[hashkey];pic;pic = pic->chain) + { if (!strcmp (path, pic->name)) - if(!((pic->texflags ^ texflags) & ~(TEXF_COMPRESS))) // ignore TEXF_COMPRESS when comparing, because fallback pics remove the flag + { + // if it was created (or replaced) by Draw_NewPic, just return it + if(pic->flags & CACHEPICFLAG_NEWPIC) + return pic; + if (!((pic->texflags ^ texflags) & ~(TEXF_COMPRESS))) // ignore TEXF_COMPRESS when comparing, because fallback pics remove the flag { if(!(cachepicflags & CACHEPICFLAG_NOTPERSISTENT)) { @@ -346,6 +351,8 @@ cachepic_t *Draw_CachePic_Flags(const char *path, unsigned int cachepicflags) } return pic; } + } + } if (numcachepics == MAX_CACHED_PICS) { @@ -361,6 +368,7 @@ cachepic_t *Draw_CachePic_Flags(const char *path, unsigned int cachepicflags) reload: // check whether it is an dynamic texture (if so, we can directly use its texture handler) + pic->flags = cachepicflags; pic->tex = CL_GetDynTexture( path ); // if so, set the width/height, too if( pic->tex ) { @@ -551,7 +559,7 @@ cachepic_t *Draw_NewPic(const char *picname, int width, int height, int alpha, u if (pic) { - if (pic->tex && pic->width == width && pic->height == height) + if (pic->flags == CACHEPICFLAG_NEWPIC && pic->tex && pic->width == width && pic->height == height) { R_UpdateTexture(pic->tex, pixels_bgra, 0, 0, 0, width, height, 1); return pic; @@ -575,6 +583,7 @@ cachepic_t *Draw_NewPic(const char *picname, int width, int height, int alpha, u } } + pic->flags = CACHEPICFLAG_NEWPIC; // disable texflags checks in Draw_CachePic pic->width = width; pic->height = height; if (pic->tex) -- 2.39.2