glDrawBuffer does not accept GL_COLOR_ATTACHMENT0 but glReadBuffer does?

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!

In the OpenGL® 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.

[QUOTE=RealtimeSlave;1258256]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?[/QUOTE]

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.

[QUOTE=Agent D;1258261]In the OpenGL® 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.[/QUOTE]

I see, thanks!

[QUOTE=Osbios;1258268]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.[/QUOTE]

Alright, got it! Thanks