PDA

View Full Version : how to use glCompressedTexImage2D()



ralphend
12-06-2004, 11:05 PM
Hi.
Although I want to carry out palette texture use, it does not know how a palette should be specified by glCompressedTexImage2D().
Would you show me the sample code?
I need your help well.

Ralphend

Simpleton
12-09-2004, 02:49 AM
This source code shows how to use glCompressedTexImage2D(...) for image file format *.dds that uses DXTC texture compression:

int LoadTextureDDS( char *filename )
{
NVDDSImage *pImage = NULL;
int w, h;
int m;
int level;

pImage = NVDDSLoad( filename );
if ( pImage == NULL ) return 0;
w = pImage->width;
h = pImage->height;
level = 0;
while ( w > 256 || h > 256 )
{
level++;
w = (w == 1) ? w : w >> 1;
h = (h == 1) ? h : h >> 1;
}
for ( m = 0; level < pImage->numMipmaps; level++, m++ )
{
glCompressedTexImage2D( GL_TEXTURE_2D, m, pImage->format, w, h, 0, pImage->size[level], pImage->data[level] );
w = (w == 1) ? w : w >> 1;
h = (h == 1) ? h : h >> 1;
}
NVDDSFree( pImage );

return 1;
}
I hope this sample will help you rosolve your issue.
If you have any further queries, please do not hesitate to ask me.