Skip to content

Commit

Permalink
Add is_dxt10 function to be able to conditionally encode the dxt header
Browse files Browse the repository at this point in the history
  • Loading branch information
redorav committed Feb 3, 2022
1 parent 14eaee5 commit c52b7d7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ddspp.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,12 @@ namespace ddspp
unsigned int headerSize; // Actual size of header, use this to get to image data
};

inline ddspp_constexpr bool is_dxt10(const Header& header)
{
const PixelFormat& ddspf = header.ddspf;
return (ddspf.flags & DDS_FOURCC) && (ddspf.fourCC == FOURCC_DXT10);
}

inline ddspp_constexpr bool is_compressed(DXGIFormat format)
{
return (format >= BC1_UNORM && format <= BC5_SNORM) ||
Expand Down Expand Up @@ -604,7 +610,7 @@ namespace ddspp

const Header header = *reinterpret_cast<const Header*>(sourceData + sizeof(DDS_MAGIC));
const PixelFormat& ddspf = header.ddspf;
bool dxt10Extension = (ddspf.flags & DDS_FOURCC) && (ddspf.fourCC == FOURCC_DXT10);
bool dxt10Extension = is_dxt10(header);
const HeaderDXT10 dxt10Header = *reinterpret_cast<const HeaderDXT10*>(sourceData + sizeof(DDS_MAGIC) + sizeof(Header));

// Read basic data from the header
Expand Down

0 comments on commit c52b7d7

Please sign in to comment.