Advertise on this site
Brought to you by the


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 fragment color values or fragment data will be written. If no fragment shader is active, rendering operations will generate only one fragment color per fragment and it will be written into each of the buffers specified by bufs. If a fragment shader is active and it writes a value to the output variable gl_FragColor, then that value will be written into each of the buffers specified by bufs. If a fragment shader is active and it writes a value to one or more elements of the output array variable gl_FragData[], then the value of gl_FragData[0] will be written into the first buffer specified by bufs, the value of gl_FragData[1] will be written into the second buffer specified by bufs, and so on up to gl_FragData[n-1]. The draw buffer used for gl_FragData[n] and beyond is implicitly set to be GL_NONE.

The symbolic constants contained in bufs may be any of the following:

GL_NONE

The fragment color/data value is not written into any color buffer.

GL_FRONT_LEFT

The fragment color/data value is written into the front left color buffer.

GL_FRONT_RIGHT

The fragment color/data value is written into the front right color buffer.

GL_BACK_LEFT

The fragment color/data value is written into the back left color buffer.

GL_BACK_RIGHT

The fragment color/data value is written into the back right color buffer.

GL_AUXi

The fragment color/data value is written into auxiliary buffer i.

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. The number of auxiliary buffers can be queried by calling glGet with the argument GL_AUX_BUFFERS.

Notes

glDrawBuffers is available only if the GL version is 2.0 or greater.

It is always the case that GL_AUXi = GL_AUX0 + i.

The symbolic constants GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, and GL_FRONT_AND_BACK are not allowed in the bufs array since they may refer to multiple buffers.

If a fragment shader writes to neither gl_FragColor nor gl_FragData, 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_ENUM is generated if n is less than 0.

GL_INVALID_OPERATION is generated if a symbolic constant other than GL_NONE appears more than once in bufs.

GL_INVALID_OPERATION is generated if any of the entries in bufs (other than GL_NONE ) indicates a color buffer that does not exist in the current GL context.

GL_INVALID_VALUE is generated if n is greater than GL_MAX_DRAW_BUFFERS.

GL_INVALID_OPERATION is generated if glDrawBuffers is executed between the execution of glBegin and the corresponding execution of glEnd.

Associated Gets

glGet with argument GL_MAX_DRAW_BUFFERS

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

See Also

glBlendFunc, glColorMask, glDrawBuffers, glIndexMask, glLogicOp, glReadBuffer

Copyright

Copyright © 2003-2005 3Dlabs Inc. Ltd. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.