]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
DDS support: convert DXT3/DXT5 to DXT1 when requesting non-alpha (correctness)
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 6 Sep 2011 17:26:51 +0000 (17:26 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 6 Sep 2011 17:26:51 +0000 (17:26 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11327 d7cf8633-e32d-0410-b094-e92efae38249

gl_textures.c

index 180447ff6f74856896a0782ba4f816ad24ea721f..3a5b20fcb6d2655199aa9a51a0842cd0710a27f8 100644 (file)
@@ -2199,6 +2199,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)
        {