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.
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.
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:
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.
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. The name of the default framebuffer's depth buffer (for query purposes) is GL_DEPTH.
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.
The default framebuffer can have a stencil buffer for doing stencil tests. The number of stencil bits is generally one of the parameters passed to context creation functions. The name of the default framebuffer's stencil buffer (for query purposes) is GL_STENCIL.
Stereo rendering still uses one stencil 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.
Pixel ownership test
Because the Default Framebuffer is owned by a resource external to OpenGL, it is possible that particular pixels of the default framebuffer are not owned by OpenGL. And therefore, OpenGL cannot write to those pixels. Fragments aimed at such pixels are therefore discarded at this stage of the pipeline.
Generally speaking, if the window you are rendering to is partially obscured by another window, the pixels covered by the other window are no longer owned by OpenGL and thus fail the ownership test. Any fragments that cover those pixels will be discarded. This also includes framebuffer clearing operations.
Note that this test only affects rendering to the default framebuffer. When rendering to a Framebuffer Object, all fragments pass this test.
The default framebuffer can be multisampled as well. Again, the number of samples is usually specified as a context creation parameter.
Removed buffer images
|Warning: This section describes legacy OpenGL APIs that have been removed from core OpenGL 3.1 and above (they are only deprecated in OpenGL 3.0). It is recommended that you not use this functionality in your programs.|
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.