OpenGL - DDS and sRGB colorspace

478 views Asked by At

I have checked a few examples of DDS loader implementation. Typically, detecting DXT format looks like this:

if (ddsHeader.ddsPixelFormat.dwFlags & DDSF_FOURCC) 
{
    switch (ddsHeader.ddsPixelFormat.dwFourCC) 
    {
    case FOURCC_DXT1:
    {
        format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
        break;
    }
    //etc

Detecting standard RGB format looks this way:

if (ddsHeader.ddsPixelFormat.dwFlags & DDPF_RGB) 
{
    if (ddsHeader.ddsPixelFormat.dwRGBBitCount == 24 &&
        ddsHeader.ddsPixelFormat.dwRBitMask == 0x000000FF &&
        ddsHeader.ddsPixelFormat.dwGBitMask == 0x0000FF00 &&
        ddsHeader.ddsPixelFormat.dwBBitMask == 0x00FF0000) 
    {
        format = GL_RGB8;
    }
    //etc

How to detect sRGB formats, for example GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT or GL_SRGB8_EXT ? Does DDS support sRGB formats ?

1

There are 1 answers

0
Nicol Bolas On BEST ANSWER

D3D10 introduced image formats for sRGB images. These formats could be used in an extended version of the DDS format, thereby allowing such files to declare that they contain sRGB data. Including block-compressed versions.

However, this requires both a compressor and a loader that supports DDS-10. You can tell if a loader supports DDS-10 if it checks the FOURCC for "DX10" and uses the DDS_HEADER_DXT10 header to get a DXGI format. The testing code you showed does not appear to do so.