PDA

View Full Version : dynamically generated textures...



jo blue
04-06-2000, 04:49 AM
Hi !

I want to generate a texture between to frames, in order to draw it on a quad, during the next frames. To generate my texture, I render the desired scene, and I store the back buffer without displaying it.

That's OK, I can do it with the glReadPixels() function. It stores the buffer into the processor memory. Then I can create a texture object with glGenTexture2D() and use this texture object for the next frames.

But it is very slow, because the texture is send from the video memory to the processor memory (glReadPixels), and then from the processor memory to the video memory (glGenTexture2D). The texture generation has to be very fast, otherwise the frame rate of the main scene will collapse...

Is there a way to store my new texture directly into the video memory, as a texture object ? (kind of "readPixelsIntoTexture2D()" function ...)

Thank you for your help !

Aurelien

dmy
04-06-2000, 07:08 AM
glReadPixels is notoriously slow http://www.opengl.org/discussion_boards/ubb/frown.gif , only the arb can do something on this side...
to my knowledge, there's no fast "framebuffer to texture" routine.

however to speed up things you should use glTexSubimage instead of recreate a texture object every frame.

while starting up the application, generate the texture as usual, with glGenTexture, glBindTexture and glTexImage.

then, into the heartbeat, update the texture with glTexSubimage.

Dolo/\/\ightY

Eric
04-06-2000, 09:35 AM
Depending on the effect you want to create, you could render your texture in a DIB (which is not hardware accelerated !) and then glTexSubImage the result !

This will avoid the slow glReadPixels process (but perhaps it is even slower !).

Well, if your texture is really complicated to generate, it is not worth a try but in case of a simple thing, why not... (I have never done that but if I'll probably try it one day !).

Eric

jo blue
04-07-2000, 12:39 AM
Thank you for your answers !

I have study the glTexSubImage2D() function in the red book, and I have found a very interesting one, wich is explained in the same section : glCopyTexSubImage2D(). It seems to do exactly what I want ! What do you think about that ?

Eric
04-07-2000, 01:21 AM
Hi Joe !

Yes, I have just read the specs for this function and it seems to be exactly what you wanted ! (sorry, I did not think about it...).

Try it and tell us if it is slow or acceptable !!!!

Eric

jo blue
04-10-2000, 11:09 PM
Hi !

There is a new problem : I want to generate some alpha in my texture. When I used glReadPixels(), I was able to modify my texture, and to change one color into alpha.

But now, I can't access the texture. Do you know if there is a way to generate some alpha ?

Thanks

Jo Blue