Efficient generated textures?

Started by blue_tomato, July 22, 2006, 11:55:27

Previous topic - Next topic


Basically I need to render a new texture periodically (maybe once per second or so), then store it as a compressed texture (compressed form is very important) in memory for fast drawing later.

It seems like the way to do this is through using glTexSubImage2D on an already allocated texture, however, how to make the resulting image compressed? Would I need to code my own compressor? Or does the card have hardware support for this somehow?

Do you know how to achieve this in LWJGL?

Thanks :)


GL11.glTexImage2D(GL_TEXTURE_2D, 0, ARBTextureCompression.COMPRESSED_RGBA_ARB, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, myByteBuffer);

your bytebuffer contains the uncompressed data, the GL will compress it for you as RGBA; Look at EXT_Texture_Compression_S3TC too to get DXT compression.

Whether its effecient or not is a different matter. I suggest you have a look at DXT compression as the B component can be obtained from the R and G components and hence, quick to decode, and quick to encode. This way, you could encode *while* generating which saves you a few pixel touches in the loops.



GL11.glTexImage2D(GL_TEXTURE_2D, 0, ARBTextureCompression.GL_COMPRESSED_RGBA_ARB, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, myByteBuffer);



boo frikidy hoo :P

But yes, your right