]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_textures.c
changed executable name detection to ignore path
[xonotic/darkplaces.git] / gl_textures.c
index 180447ff6f74856896a0782ba4f816ad24ea721f..2302eef8abb7f9cdfffca58353dc125c71721936 100644 (file)
@@ -2033,7 +2033,9 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen
        int mip, mipwidth, mipheight, mipsize, mipsize_total;
        unsigned int c;
        GLint oldbindtexnum = 0;
-       const unsigned char *mippixels, *ddspixels, *mippixels_start;
+       const unsigned char *mippixels;
+       const unsigned char *mippixels_start;
+       unsigned char *ddspixels;
        unsigned char *dds;
        fs_offset_t ddsfilesize;
        unsigned int ddssize;
@@ -2199,6 +2201,18 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen
                return NULL;
        }
 
+       // when requesting a non-alpha texture and we have DXT3/5, convert to DXT1
+       if(!(flags & TEXF_ALPHA) && (textype == TEXTYPE_DXT3 || textype == TEXTYPE_DXT5))
+       {
+               textype = TEXTYPE_DXT1;
+               bytesperblock = 8;
+               ddssize -= 128;
+               ddssize /= 2;
+               for (i = 0;i < ddssize;i += bytesperblock)
+                       memcpy(&ddspixels[i], &ddspixels[(i<<1)+8], 8);
+               ddssize += 128;
+       }
+
        force_swdecode = false;
        if(bytesperblock)
        {