PDA

View Full Version : glDrawBuffer does not accept GL_COLOR_ATTACHMENT0 but glReadBuffer does?



RealtimeSlave
03-09-2014, 09:00 AM
Hello,

I see lots of code around the web where the following is done:


glDrawBuffer(GL_COLOR_ATTACHMENT0);

But looking into the manual glDrawBuffer (in contrast to glReadBuffer and glDrawBuffers)
does NOT accept GL_COLOR_ATTACHMENTX as parameter.

So wondering what is the proper usage of glDrawBuffer and why does glReadBuffer
accept color attachments but glDrawBuffer does not?

I am also a bit confused how to setup things with glReadBuffer/glDrawBuffer/glDrawBuffers
when doing a glBlitFramebuffer on a framebuffer which has only a depth/depth-stencil texture
attached but no color attachment at all?

Help is really appreciated!

Agent D
03-09-2014, 12:13 PM
In the OpenGL(R) 3.3 specification, it says, that glDrawBuffer accepts an enumerator from tables 4.4 or 4.5. Table 4.5 lists the enumerators NONE and COLOR_ATTACHMENTi with the caption underneath saying that this is perfectly fine when "...the context is bound to a framebuffer object".

I guess that the man pages just lag behind or whoever's responsible missed to update that section.

Osbios
03-10-2014, 08:30 AM
I am also a bit confused how to setup things with glReadBuffer/glDrawBuffer/glDrawBuffers
when doing a glBlitFramebuffer on a framebuffer which has only a depth/depth-stencil texture
attached but no color attachment at all?

A framebuffer can only have one depth and/or one stencil target. This can be as two separate buffers or as one combination buffer.
You tell glBlitFramebuffer what combination of depth/stencil/color you want to copy via bitmask. Because there is only one depth and one stencil you don't have to preselect them like the color targets.

For a framebuffer without any color targets you would only set GL_DEPTH_BUFFER_BIT and/or GL_STENCIL_BUFFER_BIT. And the value of glReadBuffer/glDrawBuffer/glDrawBuffers doesn't matter.

RealtimeSlave
03-11-2014, 11:32 AM
In the OpenGL(R) 3.3 specification, it says, that glDrawBuffer accepts an enumerator from tables 4.4 or 4.5. Table 4.5 lists the enumerators NONE and COLOR_ATTACHMENTi with the caption underneath saying that this is perfectly fine when "...the context is bound to a framebuffer object".

I guess that the man pages just lag behind or whoever's responsible missed to update that section.

I see, thanks!



A framebuffer can only have one depth and/or one stencil target. This can be as two separate buffers or as one combination buffer.
You tell glBlitFramebuffer what combination of depth/stencil/color you want to copy via bitmask. Because there is only one depth and one stencil you don't have to preselect them like the color targets.

For a framebuffer without any color targets you would only set GL_DEPTH_BUFFER_BIT and/or GL_STENCIL_BUFFER_BIT. And the value of glReadBuffer/glDrawBuffer/glDrawBuffers doesn't matter.

Alright, got it! Thanks