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.