viktorzeid
viktorzeid

Reputation: 1561

Explain different types of draw buffers

Why do we need all these buffers:

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.

GL_FRONT and GL_BACK make sense to me, but not others. Can someone give an example when we will be rendering to say GL_BACK_LEFT?

When I say GL_FRONT_ABD_BACK, does it render to all left and right of both front and back buffers (ie 4 buffers in total). What are the use-cases of rendering the same image to all 4 buffers? Any examples?

Upvotes: 0

Views: 2067

Answers (2)

Reto Koradi
Reto Koradi

Reputation: 54642

The LEFT/RIGHT distinction for the buffers is used for stereo display. For double buffered stereo, you would render the image for the left eye into the GL_BACK_LEFT buffer, the image for the right eye into the GL_BACK_RIGHT buffer, and then swap buffers.

In stereo mode, GL_BACK is used if you want to render the same thing to both GL_BACK_LEFT_ and GL_BACK_RIGHT. Which is quite rare.

You're correct about GL_FRONT_AND_BACK. Rendering to the front buffer is long obsolete, and was only useful in special cases anyway. One typical case was for drawing special cursors, like cross-hair cursors, using OpenGL, on top of an already displayed frame. Rendering to both front and back at the same time was even less useful. I can't think of a good use case right now.

AUX buffers are long deprecated as well. I believe they were intended for rendering effects where you needed additional color buffers. These days, you would use FBOs for the same purpose.

Upvotes: 4

Drew Hall
Drew Hall

Reputation: 29065

The FRONT and BACK distinction refers to double buffering--usually a program draws to the back buffer and then swaps it to the front such that a complete frame is always presented to the user.

The LEFT and RIGHT distinction is for stereo rendering (where a slightly different viewpoint is used to render images for the left and right eyes).

Of course, most stereo rendering hardware would also support double buffering, leading to the combinations GL_FRONT/BACK_LEFT/RIGHT.

What buffers are actually available depends on the context you have requested and (of course) the capabilities of the underlying system. GL_FRONT is likely to have the same defined value as one or the other of GL_FRONT_LEFT and GL_FRONT_RIGHT, and likewise for GL_BACK, though there's no guarantee.

The GL_AUXi buffers are implementation specific. I suspect they're usually used for overlay planes when available.

Upvotes: 1

Related Questions