Skip to content

Commit

Permalink
Consider no mipmaps present when mipmap count is 1
Browse files Browse the repository at this point in the history
that is correct, although somewhat unlogical imo
  • Loading branch information
Morilli committed Jan 23, 2022
1 parent 874f20c commit fff5cb7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void dds2tex(const char* dds_path)
fclose(dds_file);
return;
}
if (dds_header.dwMipMapCount > 0) {
if (dds_header.dwMipMapCount > 1) { // this value may be set to 1, which is equivalent to leaving it at 0 (no mipmaps)
if (dds_header.dwMipMapCount != 32u - __builtin_clz(max(dds_header.dwWidth, dds_header.dwHeight))) {
fprintf(stderr, "Error: DDS mipmap count mismatch; expected %u mipmaps, got %u\n", 32 - __builtin_clz(max(dds_header.dwWidth, dds_header.dwHeight)), dds_header.dwMipMapCount);
fclose(dds_file);
Expand All @@ -74,7 +74,7 @@ void dds2tex(const char* dds_path)
.magic = tex_magic,
.image_width = dds_header.dwWidth,
.image_height = dds_header.dwHeight,
.has_mipmaps = dds_header.dwMipMapCount
.has_mipmaps = dds_header.dwMipMapCount > 1
};
memcpy(tex_header.tex_format, tex_format, 2);
fwrite(&tex_header, sizeof(TEX_HEADER), 1, tex_file);
Expand Down

0 comments on commit fff5cb7

Please sign in to comment.