On Sun, 18 Nov 2012 15:52:43 +0000, VelociChicken wrote:
> Hello again. I'm getting a little confused over the glDrawBuffers
> function.
>
> Is glDrawBuffers a state change or... Is glDrawBuffers a command that
> draws everything sent so far?
It's a state change. It sets the association between the elements
of gl_FragData[] and specific colour buffers.
> I'm asking becauseit seems to swap between the two.
Any command may perform an implicit glFlush().
> But it has to be set AFTER glBindFramebufferEXT is called, because
> glDrawBuffers appears to be associated with each frame buffer rather
> than a universal setting for all.
Correct. The draw-buffer and read-buffer bindings are per-framebuffer
state.
In fact, it could not be otherwise.
If a context is bound to the default framebuffer, the draw and read
buffers must be one of GL_FRONT, GL_BACK, GL_FRONT_LEFT, etc, while if it
is bound to a FBO, they must be one of the GL_COLOR_ATTACHMENTn names.
Similarly, only colour buffers which exist in the currently-bound
framebuffer can be used (e.g. you can't use e.g. GL_COLOR_ATTACHMENT3
with a FBO which only has one colour buffer).
If the bindings were global, any setting which was valid for the default
framebuffer would become invalid when a FBO was bound, and vice versa.
But any such error is generated when you call glDrawBuffers() or similar,
not when calling glBindFramebuffer().