PDA

View Full Version : fbo - read previous / write to current



powermax
06-17-2008, 04:00 PM
Hi

Im rendering to a fbo texture and i want to use that texture in the next frame while also rendering to the same texture.
So I probably need a copy of that fbo texture. What is the best way to do this? If possible without copying to the cpu.

thx

-NiCo-
06-18-2008, 02:48 AM
Why don't you use another texture to write to? This will avoid an extra memory copy. In a ping-pong setup:

pass 1:
read from tex 1
write to tex 2
use tex2 for rendering

pass 2:
read from tex2
write to tex1
use tex1 for rendering

pass 3:
read from tex 1
write to tex 2
use tex2 for rendering


If you still want to go about it your way, I suggest using glCopyTexSubImage or FBO blitting.

powermax
06-18-2008, 12:41 PM
I initially thought that it just wasnt possible to read and write to the same fbo, because i apparently made some mistakes. But it is only not possible to read and write to the same fbo texture. I fixed my code and the ping-pong setup works now.

Thanks very much

-NiCo-
06-18-2008, 01:33 PM
Actually, it is possible to read and write to the same fbo texture, but the results will be undefined ;)