Texture Compression Options

Started by elias4444, January 31, 2006, 22:17:34

Previous topic - Next topic

elias4444

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.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias

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

elias4444

Is there a way to use that compression with gluBuild2DMipmaps()? I only know how to put the source format into that one.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias

Not a way I can see, sorry.

- elias

elias4444

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. :)
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com