PDA

View Full Version : Texture Compression



Rapzoph
01-04-2012, 05:43 AM
Hello all,

Have come across a problem with texture compression in OpenGL that i can't get my head round.

I'm trying to load a DXT3 texture. The system finds the texture and loads it without error but it is rendered 'white'.

I created the dds file from a .tga using NVDIA texture tools and and ATI TheCompressonator and the issue is the same in both cases.

This is the code I use to define the texture. in_pCompressedTextureFile is a pointer to my dds file reader. The dds file contains only the main texture, with no mipmaps.




glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

int iWidth = in_pCompressedTextureFile->GetWidth();
int iHeight = in_pCompressedTextureFile->GetHeight();
int iSize = ( ( iWidth + 3 ) / 4 ) * ( ( iHeight + 3 ) / 4 ) * 16;
glCompressedTexImage2D( GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, iWidth,iHeight , 0, iSize, in_pCompressedTextureFile->GetData() );



I've attached 2 images. The first is the tga ( with alpha channel ), the compressed file and the difference file; all in The Compressonator. The second is the result in my OpenGL program.

Any help would be nice :)
Thankyou.

ZbuffeR
01-04-2012, 06:26 AM
This is not white, it is semi-garbage.
Have you checked for GL errors after each GL call ?
http://www.opengl.org/wiki/GL_Error_Codes

Rapzoph
01-04-2012, 10:49 AM
Yes, glGetError() returns GL_NO_ERROR.

Alfonse Reinheart
01-04-2012, 11:17 AM
Are you sure it's actually DXT3 compressed?

Rapzoph
01-04-2012, 11:22 AM
The dds file header says it is.

Rapzoph
01-04-2012, 11:51 AM
Do I have to do anything speacial on the shader side ? or is it just like normal texture mapping in glsl ?

Rapzoph
01-04-2012, 12:19 PM
:)

I missed the second reserved field in the dds header ! There was an offset of 1 byte in the data :s.

Thanks for the pointers.