I'm trying to render various scenes to a set of textures, each scene has it's own texture to where it should be drawn...
The question:
How bad would be creating say 512 FBO's with 512 textures bound to each of them. Wouldn't it be better to use only one FBO, in this case I will need to unbind texture previously bound to FBO, how do I do that, or should I stick to 512 FBOs?
You detach a currently attached texture by attaching the zero texture to the same attachment point (see chapter 4.4 of the specification).
I can't tell for sure whether detaching and re-attaching textures will be faster or switching framebuffer objects, since that depends on the implementation.
Conceptually, though, attaching and detaching textures means twice as many library calls and twice as many framebuffer completeness checks have to be made in the driver, so I would assume that using several FBOs will be faster (though 512 is a stunning number!).
However, very possibly, an implementation might do these checks in a lazy manner (any time after touching any attachment, and just before the first draw command happens), so it's impossible to tell for sure.
Use only one FBO, and attach textures to it. When you attach another texture, the original texture is unattached from the FBO.
Also, you can attach texture ID 0 to the FBO to unattach the current texture from the FBO.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With