Light | Dark

glDrawBuffers

Name

glDrawBuffers — Specifies a list of color buffers to be drawn into

C Specification

void glDrawBuffers( GLsizei n,
const GLenum *bufs);

Parameters

n

Specifies the number of buffers in bufs.

bufs

Points to an array of symbolic constants specifying the buffers into which fragment colors or data values will be written.

Description

glDrawBuffers defines an array of buffers into which outputs from the fragment shader data will be written. If a fragment shader writes a value to one or more user defined output variables, then the value of each variable will be written into the buffer specified at a location within bufs corresponding to the location assigned to that user defined output. The draw buffer used for user defined outputs assigned to locations greater than or equal to n is implicitly set to GL_NONE and any data written to such an output is discarded.

The symbolic constants contained in bufs must be one of the following, depending on whether GL is bound to the default framebuffer or not:

GL_NONE

The fragment shader output value is not written into any color buffer.

GL_BACK

The fragment shader output value is written into the back color buffer.

GL_COLOR_ATTACHMENT n

The fragment shader output value is written into the nth color attachment of the current framebuffer. n may range from zero to the value of GL_MAX_COLOR_ATTACHMENTS.

Except for GL_NONE, the preceding symbolic constants may not appear more than once in bufs. The maximum number of draw buffers supported is implementation dependent and can be queried by calling glGet with the argument GL_MAX_DRAW_BUFFERS.

Notes

If a fragment shader does not write to a user defined output variable, the values of the fragment colors following shader execution are undefined. For each fragment generated in this situation, a different value may be written into each of the buffers specified by bufs.

Errors

GL_INVALID_ENUM is generated if one of the values in bufs is not an accepted value.

GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and n is not 1, or if the value in bufs is one of the GL_COLOR_ATTACHMENTn tokens.

GL_INVALID_OPERATION is generated if the GL is bound to a framebuffer object and the ith buffer listed in bufs is anything other than GL_NONE or GL_COLOR_ATTACHMENTSi.

GL_INVALID_VALUE is generated if n is less than 0 or greater than GL_MAX_DRAW_BUFFERS.

Associated Gets

glGet with argument GL_MAX_DRAW_BUFFERS

glGet with argument GL_DRAW_BUFFERi where i indicates the number of the draw buffer whose value is to be queried.

API Version Support

OpenGL ES API Version
Function Name 2.0 3.0 3.1
glDrawBuffers -

See Also

glReadBuffer

Think you can improve this page? Edit this page on GitHub.