GLDRAWBUFFER(3G)

๐Ÿ“ฆ version 24.3.3, in opensuse-leap 16.0

๐Ÿ’… GLDRAWBUFFER(3G) โ€” aka the glDrawBuffer era ๐ŸŽ€

Okay bestie, so this is a page from the OpenGL manual, section 3G. Sit down, grab a strawberry drink ๐Ÿ“, and let me tell you about the moment where your app decides where the colors actually land. It's giving "which mailbox do I drop this letter in" but make it graphics.


โœจ C SPECIFICATION โœจ

void glDrawBuffer( GLenum mode )

Like, one function, one argument, zero vibes spared. ๐Ÿซถ


๐ŸŒธ PARAMETERS ๐ŸŒธ

  • mode โ€” tells the universe up to four color buffers to be drawn into. The symbolic constants it accepts are GL_NONE, GL_FRONT_LEFT, GL_FRONT_RIGHT, GL_BACK_LEFT, GL_BACK_RIGHT, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, GL_FRONT_AND_BACK, and GL_AUXi, where i is between 0 and "GL_AUX_BUFFERS" - 1. And before you @ me: GL_AUX_BUFFERS is not the upper limit โ€” use glGet to query the number of available aux buffers, iykyk. The initial value is GL_FRONT for single-buffered contexts, and GL_BACK for double-buffered contexts.

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So like, when colors are written to the frame buffer, they get written into the color buffers that glDrawBuffer picks. The specs are as follows, and yes I'm listing all of them, no cap:

  • GL_NONE โ€” No color buffers are written. None. Zero. Empty. ๐Ÿ’€
  • GL_FRONT_LEFT โ€” Only the front left color buffer is written.
  • GL_FRONT_RIGHT โ€” Only the front right color buffer is written.
  • GL_BACK_LEFT โ€” Only the back left color buffer is written.
  • GL_BACK_RIGHT โ€” Only the back right color buffer is written.
  • GL_FRONT โ€” Only the front left and front right color buffers are written. If there is no front right color buffer, only the front left color buffer is written.
  • GL_BACK โ€” Only the back left and back right color buffers are written. If there is no back right color buffer, only the back left color buffer is written.
  • GL_LEFT โ€” Only the front left and back left color buffers are written. If there is no back left color buffer, only the front left color buffer is written.
  • GL_RIGHT โ€” Only the front right and back right color buffers are written. If there is no back right color buffer, only the front right color buffer is written.
  • GL_FRONT_AND_BACK โ€” All the front and back color buffers (front left, front right, back left, back right) are written. If there are no back color buffers, only the front left and front right color buffers are written. If there are no right color buffers, only the front left and back left color buffers are written. If there are no right or back color buffers, only the front left color buffer is written. The way this one has layers ๐Ÿ˜ญ๐Ÿ‘‘
  • GL_AUXi โ€” Only auxiliary color buffer i is written.

Now the spicy part ๐ŸŒถ๏ธ: if more than one color buffer is selected for drawing, then blending or logical operations are computed and applied independently for each color buffer and can produce different results in each buffer. Main character energy per buffer, honestly.

Monoscopic contexts include only left buffers, and stereoscopic contexts include both left and right buffers. Likewise, single-buffered contexts include only front buffers, and double-buffered contexts include both front and back buffers. The context is selected at GL initialization. Periodt.


๐ŸŽ€ NOTES ๐ŸŽ€

It is always the case that GL_AUXi = GL_AUX0 + i. Math stays mathing. ๐Ÿงฎโœจ


๐Ÿ’… ERRORS ๐Ÿ’…

  • GL_INVALID_ENUM is generated if mode is not an accepted value.
  • GL_INVALID_OPERATION is generated if none of the buffers indicated by mode exists.
  • GL_INVALID_OPERATION is generated if glDrawBuffer is executed between the execution of glBegin and the corresponding execution of glEnd.
Not me getting an error because I called it in the middle of a glBegin/glEnd block ๐Ÿ™ˆ Don't be that girl.

๐ŸŒˆ ASSOCIATED GETS ๐ŸŒˆ

  • glGet with argument GL_DRAW_BUFFER
  • glGet with argument GL_AUX_BUFFERS

๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ

glBlendFunc(3G), glColorMask(3G), glIndexMask(3G), glLogicOp(3G), glReadBuffer(3G)


Okay that's the whole page, bestie โ€” every flag, every fallback case, every error, all of it. Slay. ๐Ÿ’–

Sign-off time: this one's from the OpenGL manual, section GLDRAWBUFFER(3G), and the footer of the original was the same GLDRAWBUFFER(3G) marker. Go draw into your buffers responsibly, queen ๐Ÿ‘‘๐Ÿฆ‹๐Ÿ’œ

๐Ÿ“ฆ where this page comes from