开发者

How to unbind texture from a frame buffer

开发者 https://www.devze.com 2023-03-20 22:45 出处:网络
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...

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开发者_JAVA技巧 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消