]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Fix drawflag handling in Mod_Mesh_GetTexture by duplicating texture_t when drawflag...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 22 Jan 2020 09:25:29 +0000 (09:25 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 22 Jan 2020 09:25:29 +0000 (09:25 +0000)
This fixes a menu issue in Steel Storm: Burning Retribution where the black text over a hover button was being rendered as MATERIALFLAG_ADD due to DRAWFLAG_ADD being used earlier in the frame on the same font image, which made the text invisible.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12505 d7cf8633-e32d-0410-b094-e92efae38249

model_shared.c
model_shared.h

index 73d87d2d22c6beb81cd7eca91c2362ad2b1d635e..1e546719f171558f8ea726bc7f5b4535a9cb2738 100644 (file)
@@ -4398,9 +4398,10 @@ texture_t *Mod_Mesh_GetTexture(dp_model_t *mod, const char *name, int defaultdra
 {
        int i;
        texture_t *t;
-       for (i = 0; i < mod->num_textures; i++)
-               if (!strcmp(mod->data_textures[i].name, name))
-                       return mod->data_textures + i;
+       int drawflag = defaultdrawflags & DRAWFLAG_MASK;
+       for (i = 0, t = mod->data_textures; i < mod->num_textures; i++, t++)
+               if (!strcmp(t->name, name) && t->drawflag == drawflag)
+                       return t;
        if (mod->max_textures <= mod->num_textures)
        {
                texture_t *oldtextures = mod->data_textures;
@@ -4412,6 +4413,7 @@ texture_t *Mod_Mesh_GetTexture(dp_model_t *mod, const char *name, int defaultdra
        }
        t = &mod->data_textures[mod->num_textures++];
        Mod_LoadTextureFromQ3Shader(mod->mempool, mod->name, t, name, false, true, defaulttexflags, defaultmaterialflags);
+       t->drawflag = drawflag;
        switch (defaultdrawflags & DRAWFLAG_MASK)
        {
        case DRAWFLAG_ADDITIVE:
index 0b377c2c18f79745437ad7cee9aca9f54074ad9a..64c3c7d7995f6a22b0a58c9808181099de169c3a 100644 (file)
@@ -631,6 +631,9 @@ typedef struct texture_s
 
        // diffuse and ambient
        float rtlightambient;
+
+       // used by Mod_Mesh_GetTexture for drawflag overrides, to disambiguate the same texture with different drawflags
+       int drawflag;
 }
  texture_t;