Default Framebuffer

The Default Framebuffer is the framebuffer that OpenGL is created with. It is created along with the OpenGL Context. Like Framebuffer Objects, the default framebuffer is a series of images. Unlike FBOs, one of these images usually represents what you actually see on some part of your screen.

Contents

Creation

The default framebuffer is created at the time the OpenGL context is constructed. The desired properties of the default framebuffer are given to the context creation functions, which will take these into consideration when creating the context. The construction of a context is platform-specific, so exactly how you specify your desired properties is platform-specific.

The default framebuffer contains a number of images, based on how it was created. All default framebuffer images are automatically resized to the size of the output window, as it is resized.

Color buffers

The default framebuffer contains up to 4 color buffers, named GL_FRONT_LEFT, GL_BACK_LEFT, GL_FRONT_RIGHT, and GL_BACK_RIGHT. The left and right buffers are used for stereoscopic rendering. Most consumer graphics cards cannot use these for doing stereoscopic 3D visualization.

If stereo rendering is not being done, then only the left buffers will be active. Attempts to read from or draw to the right buffers would fail.

Multiple buffer aliases

The default framebuffer's set of 4 color images have certain aliases that represent multiple buffers. These names are GL_LEFT, GL_RIGHT, GL_FRONT, GL_BACK, and GL_FRONT_AND_BACK; they represent the left, right, front, back, or all four buffers. These are only allowed in glDrawBuffer​ (not glDrawBuffers​; note the "s") and glReadBuffer​.

When used for rendering outputs, multiple buffer aliases mean that all of the specified buffers get the same colors. When used for reading operations, the multiple buffer aliases specify a single buffer. The rule is that it specifies the frontmost, leftmost buffer of the ones that it covers. In tabular form:

Alias

Real Image

GL_LEFT

GL_FRONT_LEFT

GL_RIGHT

GL_FRONT_RIGHT

GL_FRONT

GL_FRONT_LEFT

GL_BACK

GL_BACK_LEFT

GL_FRONT_AND_BACK

GL_FRONT_LEFT

Double buffering

The front and back buffers represent a double-buffered framebuffer. The front buffer is, more or less, what you see on the screen. The back buffer is the image that is typically rendered to. When the user wants the rendered image to become visible, they call a platform-specific buffer swapping command. This effectively transfers the back buffer data into the front buffer.

Rendering into, or reading from, the front buffer is not advisable.

The buffer swap does not have to be a true swap. In a true swap, the back buffer becomes the front buffer and vice-versa. If you were to read from the back buffer after a true swap, it would hold the previous contents of the front buffer.

That being said, OpenGL does not require true swapping. All that is required is that the contents of the back buffer find their way into the front buffer. This could be via a true swap, or it could be via a copy from the back buffer into the front.

Stereo rendering has two back buffers and two front buffers. Swapping performs the switch on both.

Depth buffer

The default framebuffer can have a Depth Buffer, which can be used for depth testing. The precision of the depth buffer is generally one of the parameters passed to the context creation functions.

Stereo rendering still uses one depth buffer. It must be shared among the left and right buffers, so a clear may need to be issued between rendering to the left and right buffers.

In compatibility contexts or OpenGL 3.0 and below, the default framebuffer can contain a plethora of other image buffers. It can contain a number of auxiliary color images; these are simply off-screen color buffers of the same size as the window. They can be rendered to and blitted from just like any other image. These are named GL_AUXi, where i is a number from 0 to the number of auxiliary buffers.

The default framebuffer can also contain an accumulation buffer, which can be used to perform certain computations when rendering.