Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unbind texture from a frame buffer

Tags:

opengl

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?

like image 747
Lu4 Avatar asked Jul 18 '11 18:07

Lu4


2 Answers

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.

like image 147
Damon Avatar answered Oct 22 '22 09:10

Damon


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.

like image 33
Dr. Snoopy Avatar answered Oct 22 '22 09:10

Dr. Snoopy