LWJGL Forum

Programming => OpenGL => Topic started by: elias4444 on January 31, 2006, 22:17:34

Title: Texture Compression Options
Post by: elias4444 on January 31, 2006, 22:17:34
I'm fiddling around with my textures again.  :wink:
What's the best texture compression method, and how do you use it? I'm looking for one that'd be supported by most cards out there these days (if there even is one). I'd like to use some higher resolution textures (over 512x512) but don't want to be a memory hog about it.

P.S. if ARB_texture_compression is the best way to go, could someone please post some sample code of how to use it? I can't find a tutorial anywhere.
Title: Texture Compression Options
Post by: elias on February 01, 2006, 07:49:36
Just using the generic compressed texture formats from ARB_texture_compression (or GL13) is quite well supported. It's quite easy to use:

GL11.glTexImage2D(GL11.GL_TEXTURE_2D, <mipmap>, GL_COMPRESSED_RGB, <width>, <height>, 0, <format>, <type>, <data>);

The great thing about using a generic format (instead of a specific one like s3tc) is that you don't have to worry about selecting the best supported method for a given card. However, you risk that some odd ball card compresses your textures to something unacceptable. It hasn't happened to us yet, though (at least not for regular RGB textures).

- elias
Title: Texture Compression Options
Post by: elias4444 on February 01, 2006, 15:26:19
Is there a way to use that compression with gluBuild2DMipmaps()? I only know how to put the source format into that one.
Title: Texture Compression Options
Post by: elias on February 01, 2006, 15:41:40
Not a way I can see, sorry.

- elias
Title: Texture Compression Options
Post by: elias4444 on February 01, 2006, 18:20:09
Found it!

If you subsitute the texture format in place of the number of generated textures in the gluBuild2DMipMap() command, it'll use the texture compression instead. Example:

GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D,GL13.GL_COMPRESSED_RGBA, get2Fold(bufferedImage.getWidth()), get2Fold(bufferedImage.getHeight()), srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer);


and voila! You have compressed mipmaps for your textures. :)