From dc4219418b6d44180d5b467189262d79d0b99d14 Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 6 Sep 2011 17:26:51 +0000 Subject: [PATCH] DDS support: convert DXT3/DXT5 to DXT1 when requesting non-alpha (correctness) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11327 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_textures.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gl_textures.c b/gl_textures.c index 180447ff..3a5b20fc 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -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) { -- 2.39.2