]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fixed gfx/menuplyr handling - Draw_NewPic now flags the cachepic_t with
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 24 Jun 2011 01:38:21 +0000 (01:38 +0000)
committerRudolf Polzer <divVerent@xonotic.org>
Sun, 26 Jun 2011 05:49:34 +0000 (07:49 +0200)
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
gl_draw.c

diff --git a/draw.h b/draw.h
index 2019e86c7cbdbc3ca2c13cbba4fc16dc55cd0d0b..2a5681a987bad7ea5c7fb495273a34b5641161b8 100644 (file)
--- 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;
 
index 01329fcb8e7eb5263ee96af18b9731f5fd6c585f..ef1fee21241ecccbc7803fc06dbe00beb29f6a8f 100644 (file)
--- 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)