LWJGL Forum

Programming => OpenGL => Topic started by: blue_tomato on July 22, 2006, 11:55:27

Title: Efficient generated textures?
Post by: blue_tomato on July 22, 2006, 11:55:27
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 :)
Title: Efficient generated textures?
Post by: darkprophet on July 22, 2006, 22:33:59

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.

DP
Title: Efficient generated textures?
Post by: Rasengan on July 23, 2006, 19:56:44
GL11.glTexImage2D(GL_TEXTURE_2D, 0, ARBTextureCompression.GL_COMPRESSED_RGBA_ARB, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, myByteBuffer);

:wink:
Title: Efficient generated textures?
Post by: darkprophet on July 24, 2006, 01:01:45
boo frikidy hoo :P

But yes, your right

DP