From 8c453f168396e5baae6df2aee522ac802068f783 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 15 Jan 2025 19:18:04 +0000 Subject: [PATCH] fix: support dds files that lie about their mipmaps --- src/ObjImage/Image/DdsLoader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ObjImage/Image/DdsLoader.cpp b/src/ObjImage/Image/DdsLoader.cpp index bc9e0c99..f61a439b 100644 --- a/src/ObjImage/Image/DdsLoader.cpp +++ b/src/ObjImage/Image/DdsLoader.cpp @@ -184,7 +184,11 @@ namespace dds m_width = header.dwWidth; m_height = header.dwHeight; m_depth = header.dwDepth; - m_has_mip_maps = (header.dwCaps & DDSCAPS_MIPMAP) != 0 || header.dwMipMapCount > 1; + + // Best thing to do here would be to check (header.dwCaps & DDSCAPS_MIPMAP) != 0 but some tools just create bad files + // I encountered both files that have the flag without them actually having mipmaps (mipMapCount == 1) + // and also files that have mipMapCount > 1 but not the flag + m_has_mip_maps = header.dwMipMapCount > 1; if (header.dwCaps2 & DDSCAPS2_CUBEMAP) m_texture_type = TextureType::T_CUBE;