Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GL_DRAW/READ_FRAMEBUFFER vs GL_FRAMEBUFFER?

I've noticed that there now are the GL_DRAW/READ_FRAMEBUFFER extensions. Currently I am simply using GL_FRAMEBUFFER and glTextureBarrierNV. However, I have not found that much about the READ/WRITE extensions and thus have some questions.

What OpenGL version were they introduced? What advantages do they give over using simply GL_FRAMEBUFFER for both read and write? Where can I find more info about this?

like image 657
ronag Avatar asked Dec 17 '11 18:12

ronag


2 Answers

Pedantic note: GL_DRAW/READ_FRAMEBUFFER were not introduced in an extension; they are core OpenGL 3.0 functionality. Yes, technically this functionality is also exposed in ARB_framebuffer_objects, but that is a core extension and it is still core GL 3.0.

In any case, if you want the etymology of the DRAW/READ distinction, you need to look to EXT_framebuffer_blit. That is where those enumerators originated, and that is why those enumerators exist. Instead of just specifying two FBOs to blit from/to, they created two context binding points for framebuffers. The glBlitFramebuffer command blits from the currently bound READ_FRAMEBUFFER to the currently bound DRAW_FRAMEBUFFER.

If you are not using blit, then you don't really need the DRAW/READ distinction. That doesn't mean you shouldn't use it however. glReadPixels reads from the READ_FRAMEBUFFER. Binding to GL_FRAMEBUFFER binds to both points, so your code can still work. But it is sometimes useful to have an FBO binding which can be read from that doesn't interfere with drawing operations.

like image 190
Nicol Bolas Avatar answered Oct 30 '22 04:10

Nicol Bolas


In case you mean the GL_READ_FRAMEBUFFER and GL_DRAW_FRAMEBUFFER constants, these come from the EXT_framebuffer_blit extension, which was later made core in OpenGL 3.0 and into a special ARB_framebuffer_object extension (together with EXT_framebuffer_multisample and the original EXT_framebuffer_object, of course) for versions <3.

They allow you to bind separate FBOs for reading and drawing operations. This is especially useful for the FBO to FBO copy operations introduced by EXT_framebuffer_blit (which allow you to copy data directly from one FBO to another) and for the resolving of multisampled FBOs introduced (and needed) by EXT_framebuffer_multisample, which actually builds ontop of the afore mentioned blit extension. When binding an FBO to GL_FRAMEBUFFER, you actually bind it to both GL_READ_FRAMEBUFFER and GL_DRAW_FRAMEBUFFER.

Like said all these FBO extension were made core in OpenGL 3.0, but may also be available to earlier versions. Look here for more information.

like image 26
Christian Rau Avatar answered Oct 30 '22 02:10

Christian Rau