Skip to content

Commit

Permalink
Merge pull request #351 from Laupetin/fix/invalid-dds-mip-map-flags
Browse files Browse the repository at this point in the history
fix: support dds files that lie about their mipmaps
  • Loading branch information
Laupetin authored Jan 15, 2025
2 parents aa73dca + 8c453f1 commit 74f84cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ObjImage/Image/DdsLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 74f84cb

Please sign in to comment.