DDPF_ALPHA=2,// Used in some older DDS files for alpha channel only uncompressed data(dwRGBBitCount contains the alpha channel bitcount; dwABitMask contains valid data)
DDPF_RGB=8,// Texture contains uncompressed RGB data; dwRGBBitCount and the RGB masks(dwRBitMask, dwGBitMask, dwBBitMask) contain valid data. 0x40
DDPF_YUV=16,//Used in some older DDS files for YUV uncompressed data(dwRGBBitCount contains the YUV bit count; dwRBitMask contains the Y mask, dwGBitMask contains the U mask, dwBBitMask contains the V mask)
DDPF_LUMINANCE=32,// Used in some older DDS files for single channel color uncompressed data (dwRGBBitCount contains the luminance channel bit count; dwRBitMask contains the channel mask). Can be combined with DDPF_ALPHAPIXELS for a two channel DDS file.
};
// dwCaps members
enum{
DDSCAPS_COMPLEX=8,
DDSCAPS_MIPMAP=0x400000,
DDSCAPS_TEXTURE=0x1000,// Required
};
// Not using any D3D headers here, this is cross platform and minimal.
// Boiled down from the public documentation.
structDDSPixelFormat{
uint32_tdwSize;// must be 32
uint32_tdwFlags;
uint32_tdwFourCC;
uint32_tdwRGBBitCount;
uint32_tdwRBitMask;
uint32_tdwGBitMask;
uint32_tdwBBitMask;
uint32_tdwABitMask;
};
structDDSHeader{
uint32_tdwMagic;// Magic is not technically part of the header struct but convenient to have here when reading the files.
uint32_tdwSize;// must be 124
uint32_tdwFlags;
uint32_tdwHeight;
uint32_tdwWidth;
uint32_tdwPitchOrLinearSize;// The pitch or number of bytes per scan line in an uncompressed texture; the total number of bytes in the top level texture for a compressed texture
uint32_tdwDepth;// we'll always use 1 here
uint32_tdwMipMapCount;
uint32_tdwReserved1[11];
DDSPixelFormatddspf;
uint32_tdwCaps;
uint32_tdwCaps2;// nothing we care about
uint32_tdwCaps3;// unused
uint32_tdwCaps4;// unused
uint32_tdwReserved2;
};
// DDS header extension to handle resource arrays, DXGI pixel formats that don't map to the legacy Microsoft DirectDraw pixel format structures, and additional metadata.
structDDSHeaderDXT10{
uint32_tdxgiFormat;
uint32_tresourceDimension;// 1d = 2, 2d = 3, 3d = 4. very intuitive
uint32_tmiscFlag;
uint32_tarraySize;// we only support 1 here
uint32_tmiscFlags2;// sets alpha interpretation, let's not bother
};
// Simple DDS parser, suitable for texture replacement packs.
// Doesn't actually load, only does some logic to fill out DDSLoadInfo so the caller can then
// do the actual load with a simple series of memcpys or whatever is appropriate.