loading DXT3 compressed mipmaps - invalid enums

I try to load a compressed texture with glCompressedTexImage2DARB(…); But on every mipmap I load, I receive an invalid enumerant error.
Here is the code: (the image is stored like in a dds-file created by the NV-PS pluggin)

glBindTexture( GL_TEXTURE_2D, neu->textureObject );

// Loading and identifying the type = DXT3

unsigned char * data = new unsigned char [ ((width+3)/4) * ((height+3)/4) * blockSize];

for(unsigned short int i = 0; i < img->numMipMaps; i++ )
{
if (width==0) width = 1;
if (height==0) height = 1;

size = ((width+3) / 4) * ((height+3) / 4) * blockSize;

fread(data, size, 1, tpak);

glCompressedTexImage2DARB( GL_TEXTURE_2D, i, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, width,
                height, 0, size, data);

errorCode = glGetError();
if( errorCode!= GL_NO_ERROR)
     log( gluErrorString(errorCode);

height &gt;&gt;= 1;
width &gt;&gt;= 1;

}

fclose(tpak);
delete []data;

I checked the error state of openGL before the slope. There is something wrong with the call to glCompressedTexImage …

ARG… I converted GL_COMPRESSED_S3TC_DXT3_EXT into a sigend int… So I passed a negative enum to the function …

Ok now there is no glError any more, but the texture shows up white…

Check that you got the blockSize variable right. It’s 8 for DXT1 but 16 for all DXT3 & DXT5.

I have a switch block in front of the slope, if the format is DXT3 and DXT5 I set the blocksize to 16 otherwise its 8 …
I just checked the supported compression formats:

glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, &num);
int *list = new int[num];
glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS_ARB, list);

And it seems that RGB_DXT1(33776), RGBA_DXT3(33778) and RGBA_DXT5(3377) are supported.

[This message has been edited by TheMummy (edited 03-28-2002).]

If you read the spec, you will see that it explains that RGBA_S3TC_DXT1 is not supposed to be listed by that because it is not a general-purpose format.

  • Matt

Here is some more info about the method.
In the file there are 7 mipmaps, and the slope calculates these values during runtime:
width:64 height:64 size:4096
width:32 height:32 size:1024
width:16 height:16 size:256
width:8 height:8 size:64
width:4 height:4 size:16
width:2 height:2 size:16
width:1 height:1 size:16

Is this correct ?
Do I have to activate something else to make it work?

Looks correct to me.