DDS files and S3TC?

Hi @ll!
I have got a few questions related to DDS files (I use the format because of S3TC)!

  1. How can I get the EXACT size of the buffer in which I can store the texture data of the DDS file? I currently use the following code:

if(ddsd.dwMipMapCount > 1)
int TempWidth = ddsd.dwWidth;
int TempHeight = ddsd.dwHeight;

for(int i = 0; i < (int)ddsd.dwMipMapCount; i++)
BufSize += ceil(TempWidth / 4) * ceil(TempHeight / 4) * TempTexture.BlockSize;

TempWidth >>= 1;
TempHeight >>= 1;

But now the problem, if there are mipmaps smaller than 44 pixels the result of ceil(TempWidth / 4) * ceil(TempHeight / 4) * TempTexture.BlockSize is zero. I know that I have to handle all mipmaps smaller than 44 with S3TC as 8 Byte blocks (when using them as OGL textures), but I can´t read them in as 8 Byte blocks, or? Anyone got an idea for me?

  1. Where can I get the MS Tool for creating DDS files? I know it´s in the DX SDK, but I don´t want to download or order the SDK.


I really need some help. Is there no one who knows how to handle these DDS files???


I’m using such a piece of code:

  RTASSERT( gl_interface.StateVector.SupportsARB_texture_compression() );
  //S3TC format
  RTASSERT( gl_interface.StateVector.SupportsEXT_texture_compression_s3tc() );
  int ddw= w, ddh= h;
  const CHAR_ARRAY& Data= Data_;
  const char* p= Data.Begin();
  for (int m= 0; mips ? m&lt;mips : m==0; ++m)
    const int sz= ((ddw+3)/4)*((ddh+3)/4)*(itf==BITMAPIO::ITF_S3TC_DXT1?8:16);
    RTASSERT( p+sz&lt;=Data.Begin()+Data.Size() );
    p+= sz;
    ddw/=2; ddh/=2; if (!ddw) ddw=1; if (!ddh) ddh=1;
  GLRESULT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mips ? minFilter : magFilter) );
  GLRESULT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter) );
  if (gl_interface.StateVector.SupportsEXT_texture_filter_anisotropic())
    GLRESULT( glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy) );

Other info, including DDS creator is available on