]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
care for the premultiplied-alpha flag when handling DDS files (use DXT2/DXT4 FOURCC...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 15 Dec 2010 12:01:47 +0000 (12:01 +0000)
committerRudolf Polzer <divverent@alientrap.org>
Thu, 16 Dec 2010 18:40:13 +0000 (19:40 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10663 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=6e45cfae05dccca77437f738a699583b6e6ed202

gl_textures.c

index 1e7b45000ab07dc3dbe900c3b783dc22a0614f7d..b5affacbe2b678218fcea8a18aa32ba1ab39e86e 100644 (file)
@@ -1671,6 +1671,15 @@ int R_SaveTextureDDSFile(rtexture_t *rt, const char *filename, qboolean skipunco
        case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: ddsfourcc = "DXT3";bytesperblock = 16;break;
        case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: ddsfourcc = "DXT5";bytesperblock = 16;break;
        }
+       // if premultiplied alpha, say so in the DDS file
+       if(glt->flags & TEXF_RGBMULTIPLYBYALPHA)
+       {
+               switch(internalformat)
+               {
+                       case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: ddsfourcc = "DXT2";break;
+                       case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: ddsfourcc = "DXT4";break;
+               }
+       }
        if (!bytesperblock && skipuncompressed)
                return -3; // skipped
        memset(mipinfo, 0, sizeof(mipinfo));
@@ -1875,6 +1884,20 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen
        }
        else if (!memcmp(dds+84, "DXT3", 4) || !memcmp(dds+84, "DXT2", 4))
        {
+               if(!memcmp(dds+84, "DXT2", 4))
+               {
+                       if(!(flags & TEXF_RGBMULTIPLYBYALPHA))
+                       {
+                               Con_Printf("^1%s: expecting DXT3 image without premultiplied alpha, got DXT2 image with premultiplied alpha\n", filename);
+                       }
+               }
+               else
+               {
+                       if(flags & TEXF_RGBMULTIPLYBYALPHA)
+                       {
+                               Con_Printf("^1%s: expecting DXT2 image without premultiplied alpha, got DXT3 image without premultiplied alpha\n", filename);
+                       }
+               }
                if(!vid.support.ext_texture_compression_s3tc)
                {
                        Mem_Free(dds);
@@ -1894,6 +1917,20 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen
        }
        else if (!memcmp(dds+84, "DXT5", 4) || !memcmp(dds+84, "DXT4", 4))
        {
+               if(!memcmp(dds+84, "DXT4", 4))
+               {
+                       if(!(flags & TEXF_RGBMULTIPLYBYALPHA))
+                       {
+                               Con_Printf("^1%s: expecting DXT5 image without premultiplied alpha, got DXT4 image with premultiplied alpha\n", filename);
+                       }
+               }
+               else
+               {
+                       if(flags & TEXF_RGBMULTIPLYBYALPHA)
+                       {
+                               Con_Printf("^1%s: expecting DXT4 image without premultiplied alpha, got DXT5 image without premultiplied alpha\n", filename);
+                       }
+               }
                if(!vid.support.ext_texture_compression_s3tc)
                {
                        Mem_Free(dds);