How to get DXT1, DXT3 by glGetCompressedTexImage?

I’m develope some texture tool like DirectX Texture Tool,
but for openGL. I can change texture internal format to any other 90 formats, except GL_COMPRESSED_RGBA_S3TC_DXT5 to DXT1 or DTX2.
Here’s my algorithm:
get uncompressed RGBA data by glGetTexImage
set glTexImage with GL_COMPRESSED_RGBA
get glGetCompressedTexImage, but always get DXT5.

How to get DXT1, DXT2 by glGetCompressedTexImage?
I don’t want to do it manually, becouse same thin with SRGBA
and have to write addition conversion code :frowning:


First, DXT2 doesn’t exist with OpenGL.
Second, if you plan to generate compressed texture using glGetCompressedTexImage … well you are just using the OpenGL drivers to generate compressed texture. Drivers are are not meant to generate compressed texture but to run real time graphics.

This imply that the OpenGL drivers DXTC compression is fast but low quality. in real case, the during the last year the nVidia compression became quiet good quality but still not that great.

I tried ATI The Compressonator, nVidia Texture tool, DirectX Texture Tool, PowerVR Texture Tools study the results and it appears that ATI The Compressonator give the best quality DXTC compression. The nVidia tool is fastest in low quality but less quality and similar speed in high quality. The DXTC compression is low quality and slow and the PowerVR Texture Tool is ok quality but reridiculously slow.

Well, to sum up: use ATI The Compressonator for DXTC compression, it’s super great! Production pipeline integration is awesome as there is a GUI but is can also be used in command line.

Yes, ATI have nice tools too!

When compressing a texture that way:
glTexImages(GL_COMPRESS_RGB, …, GL_RGB, …)

You have not control on the compression format, so you can expect choosing the format.

And by the way, glTexImages(GL_COMPRESS_RGB, …, GL_RGB, …) is really not a good think to do for the quality reasons I was saying but also because it going to make texture load slower. Build offline the compression texture using ATI The Compressonator and you are going to be sooooooo happy!

Thank Groovounet.
I think I agree with you. Since DXT1, DXT3 format is not native to openGL, then there is no need to save it. I wanted to do as much as possible is universal, but it turned out as always :slight_smile:
ATI The Compressonator is good, but I want to do it in my program.

I think you mis-spoke. DXT1 and DXT3 are native to OpenGL (as is DXT5). Well native in that everyone supports them. They have to or they’d be laughed out of town. They’d likely be core were it not for a silly patent issue.

And re DXT2: IIRC DXT2 == DXT3 and DXT4 == DXT5. Same formats!

The distinction was an implicit interpretation on whether the texture contained pre-multiplied alpha texels or non-premultiplied alpha (kinda like a shader TexEnv, but stored in the format type – odd), where DXT2/DXT4 supposedly represented pre-multiplied alpha texels, and DXT3/5 non-premultiplied-alpha.

In practice, nobody used it, and Microsoft figured out it was a dumb idea and got rid of it in DX10, where DXT2/DXT3 became BC2, and DXT4/DXT5 became BC3.

Note that DXT1 (became BC1) implicitly requires pre-multiplied alpha texel data.

So it’s not like you’re missing anything with OpenGL.

ATI The Compressonator is good, but I want to do it in my program.

Also check out Simon Brown’s free and open-source squish. Also, see Jan Paul van Waveren’s Real-time DXT Compression and Real-Time YCoCg-DXT Compression Whitepaper, if you really do want to code it up yourself – lots of provided sample code.

The NVidia OpenGL SDK 10 and CUDA SDK has real-time DXT compression, so implement it for me have not problem (even on Delhi ). But it will be only an additional feature.
I saw that after seting texture with DXT3 data like DXT5 internal format some artifacs and decide to study the structure of formats more details(thanks for link), to make an additional image processing for fix it. Guess, same can be done to for DXT1.
If I’m right, it will be cheap but good.