glBindTexture(GL_TEXTURE_2D, texture[index]);
LoadTGAFile();
if(bpp == 32)
{
imageTypeFormat = GL_RGBA;
imageTypeInternal = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
}
else
{
imageTypeFormat = GL_RGB;
imageTypeInternal = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
}
if(useMipmaps)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filterMode1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filterMode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapMode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapMode);
gluBuild2DMipmaps(GL_TEXTURE_2D, imageTypeInternal, imageWidth, imageHeight, imageTypeFormat, GL_UNSIGNED_BYTE, imageData);
}
else
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filterMode1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filterMode1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapMode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapMode);
glTexImage2D(GL_TEXTURE_2D, 0, imageTypeInternal, imageWidth, imageHeight, 0, imageTypeFormat, GL_UNSIGNED_BYTE, imageData);
}
Texture compression for uncompressed image data
I am not sure if I am setting up my compressed texture code correctly. I have uncompressed data and sending it to OpenGL. I would like to know if my code is correct...
Thanks
Yes that's correct - but one thing you might want to do is pass a generic compressed format as internal format such as GL_COMPRESSED_RGB. GL will pick automatically the best compression mode available such as DXT1, DXT3 or DXT5.
Ofcourse if you have a preference for one of the aforementioned for quality and you have made sure that that specific format is supported by the card / driver then you should be fine with your code.
Ofcourse if you have a preference for one of the aforementioned for quality and you have made sure that that specific format is supported by the card / driver then you should be fine with your code.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement