---------
Front, Back, and Other Buffers:

OpenGL stores and manipulates pixel data in a frame buffer. The frame buffer consists of a set of logical buffers: color, depth, accumulation, and stencil buffers. The color buffer itself consists of a set of logical buffers; this set can include a front left, a front right, a back left, a back right, and some number of auxiliary buffers. A particular pixel format or OpenGL implementation may not supply all of these buffers. For example, the current version of Microsoft's implementation of OpenGL in Windows NT does not support stereoscopic images, and so a pixel format cannot have left and right color buffers. In addition, the current version does not support auxiliary buffers. Refer to the Red and Blue books for further details on OpenGL buffers and the OpenGL functions that operate on them.

Microsoft's implementation of OpenGL in Windows NT supports double buffering of images. This is a technique in which an application draws pixels to an off-screen buffer, and then, when that image is ready for display, the application copies the contents of the off-screen buffer to an on-screen buffer. Double buffering enables smooth image changes, which are especially important for animated images. 
Two color buffers are available to applications that use double buffering: a front buffer and a back buffer. By default, drawing commands are directed to the back buffer, while the front buffer is displayed on the screen. When the off-screen buffer is ready for display, an application calls SwapBuffers, and Windows NT copies the contents of the off-screen buffer to the on-screen buffer.

The generic implementation uses a device-independent bitmap (DIB) as a back buffer and the screen display as a front buffer. Hardware devices and their drivers may use different approaches.
Double buffering is a pixel format property. An application requests double buffering for a pixel format by setting the PFD_DOUBLEBUFFER flag in the PIXELFORMATDESCRIPTOR data structure in a call to ChoosePixelFormat. 
The OpenGL core function glDrawBuffer selects buffers for writing and clearing.

---------
SwapBuffers:

The SwapBuffers function exchanges the front and back buffers if the current pixel format for the window referenced by the specified device context includes a back buffer. 

BOOL SwapBuffers(

    HDC  hdc	//Device context whose buffers get swapped
   );	
Parameter

hdc

Specifies a device context. If the current pixel format for the window referenced by this device context includes a back buffer, the function exchanges the front and back buffers.

Return Value

If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. Call GetLastError for extended error information.

Remarks

If the current pixel format for the window referenced by the device context does not include a back buffer, then this call has no effect. The content of the back buffer is undefined when the function returns.
A multithreaded application should flush the drawing commands in any other threads drawing to the same window before calling the SwapBuffers function.
--------
PIXELFORMATDESCRIPTOR:

typedef struct tagPIXELFORMATDESCRIPTOR { // pfd  

    WORD  nSize;
    WORD  nVersion;
    DWORD dwFlags;
    BYTE  iPixelType;
    BYTE  cColorBits;
    BYTE  cRedBits;
    BYTE  cRedShift;
    BYTE  cGreenBits;
    BYTE  cGreenShift;
    BYTE  cBlueBits;
    BYTE  cBlueShift;
    BYTE  cAlphaBits;
    BYTE  cAlphaShift;
    BYTE  cAccumBits;
    BYTE  cAccumRedBits;
    BYTE  cAccumGreenBits;
    BYTE  cAccumBlueBits;
    BYTE  cAccumAlphaBits;
    BYTE  cDepthBits;
    BYTE  cStencilBits;
    BYTE  cAuxBuffers;

    BYTE  iLayerType;
    BYTE  bReserved;
    DWORD dwLayerMask;
    DWORD dwVisibleMask;
    DWORD dwDamageMask;
} PIXELFORMATDESCRIPTOR;


The PIXELFORMATDESCRIPTOR structure describes the pixel format of a drawing surface.

Members

nSize

Specifies the size of this data structure. This value should be set to sizeof(PIXELFORMATDESCRIPTOR).

nVersion

Specifies the version of this data structure. This value should be set to 1.

dwFlags

A set of bit flags that specify properties of the pixel buffer. The properties are generally not mutually exclusive; an application can set any combination of bit flags, with the exceptions noted. The following bit flag constants are defined:

Value	Meaning
PFD_DRAW_TO_WINDOW	The buffer can draw to a window or device surface.
PFD_DRAW_TO_BITMAP	The buffer can draw to a memory bitmap.
PFD_SUPPORT_GDI	The buffer supports GDI drawing. This flag and PFD_DOUBLEBUFFER are mutually exclusive in the current generic implementation.
PFD_SUPPORT_OPENGL	The buffer supports OpenGL drawing.
PFD_GENERIC_FORMAT	The pixel format is supported by the GDI software implementation. That implementation is also known as the generic implementation. If this bit is clear, the pixel format is supported by a device driver or hardware.
PFD_NEED_PALETTE	The buffer uses RGBA pixels on a palette-managed device. A logical palette is required to achieve the best results for this pixel type. Colors in the palette should be specified according to the values of the cRedBits, cRedShift, cGreenBits, cGreenShift, cBluebits, and cBlueShift members. The palette should be created and realized in the device context (DC) before calling wglMakeCurrent.
PFD_NEED_SYSTEM_PALETTE	Used with systems with OpenGL hardware that supports one hardware palette only. For such systems to use hardware acceleration, the hardare palette must be in a fixed order (for example, 3-3-2) when in RGBA mode or must match the logical palette when in color-index mode. When you set this flag, you should call SetSystemPaletteUse in your program to force a one-to-one mapping of the logical palette and the system palette. If your OpenGL harware supports multiple hardware palettes and the device driver can allocate spare hardware palettes for OpenGL, you don't need to set PFD_NEED_SYSTEM_PALETTE.This flag is not set in the generic pixel formats.
PFD_DOUBLEBUFFER	The buffer is double-buffered. This flag and PFD_SUPPORT_GDI are mutually exclusive in the current generic implementation.
PFD_STEREO	The buffer is stereoscopic. This flag is not supported in the current generic implementation.
In addition, the following bit flags can be specified when calling ChoosePixelFormat:

Value	Meaning
PFD_DOUBLE_BUFFER_DONTCARE	The requested pixel format can be either single- or double-buffered.
PFD_STEREO_DONTCARE	The requested pixel format can be either monoscopic or stereoscopic.
With the glAddSwapHintRectWIN extension function two new flags are included for the PIXELFORMATDESCRIPTOR pixel format structure:

Value	Meaning
PFD_SWAP_COPY	Specifies the content of the back buffer in the double-buffered main color plane following a buffer swap. Swapping the color buffers causes the back-buffer content to be copied to the front buffer. The content of the back buffer is not affected by the swap. PFD_SWAP_COPY is a hint only and might not be provided by a driver.
PFD_SWAP_EXCHANGE	Specifies the content of the back buffer in the double-buffered main color plane following a buffer swap. Swapping the color buffers causes the exchange of back-buffer content with the front-buffer content. Following the swap, the back-buffer content contains the front-buffer content before the swap. PFD_SWAP_EXCHANGE is a hint only and might not be provided by a driver.
iPixelType

Specifies the type of pixel data. The following types are defined:

Value	Meaning
PFD_TYPE_RGBA	RGBA pixels. Each pixel has four components: red, green, blue, and alpha.
PFD_TYPE_COLORINDEX	Color index pixels. Each pixel uses a color index value
cColorBits

Specifies the number of color bitplanes in each color buffer. For RGBA pixel types, it is the size of the color buffer excluding the alpha bitplanes. For color index pixels, it is the size of the color index buffer.

cRedBits

Specifies the number of red bitplanes in each RGBA color buffer.

cRedShift

Specifies the shift count for red bitplanes in each RGBA color buffer.

cGreenBits

Specifies the number of green bitplanes in each RGBA color buffer.

cGreenShift

Specifies the shift count for green bitplanes in each RGBA color buffer.

cBlueBits

Specifies the number of blue bitplanes in each RGBA color buffer.

cBlueShift

Specifies the shift count for blue bitplanes in each RGBA color buffer.

cAlphaBits

Specifies the number of alpha bitplanes in each RGBA color buffer. Alpha bitplanes are not supported.

cAlphaShift

Specifies the shift count for alpha bitplanes in each RGBA color buffer. Alpha bitplanes are not supported.

cAccumBits

Specifies the total number of bitplanes in the accumulation buffer.

cAccumRedBits

Specifies the number of red bitplanes in the accumulation buffer.

cAccumGreenBits

Specifies the number of green bitplanes in the accumulation buffer.

cAccumBlueBits

Specifies the number of blue bitplanes in the accumulation buffer.

cAccumAlphaBits

Specifies the number of alpha bitplanes in the accumulation buffer.

cDepthBits

Specifies the depth of the depth (z-axis) buffer.

cStencilBits

Specifies the depth of the stencil buffer.

cAuxBuffers

Specifies the number of auxiliary buffers. Auxiliary buffers are not supported.

iLayerType

Specifies the type of layer. Although the following values are defined, the current version supports only the main plane (there is no support for overlay or underlay planes):

Value	Meaning
PFD_MAIN_PLANE	The layer is the main plane.
PFD_OVERLAY_PLANE	The layer is the overlay plane.
PFD_UNDERLAY_PLANE	The layer is the underlay plane.
bReserved

Not used. Must be zero.

dwLayerMask

Specifies the layer mask. The layer mask is used in conjunction with the visible mask to determine if one layer overlays another.

dwVisibleMask

Specifies the visible mask. The visible mask is used in conjunction with the layer mask to determine if one layer overlays another. If the result of the bitwise-AND of the visible mask of a layer and the layer mask of a second layer is nonzero, then the first layer overlays the second layer, and a transparent pixel value exists between the two layers.  If the visible mask is 0, the layer is opaque.

dwDamageMask

Specifies whether more than one pixel format shares the same frame buffer. If the result of the bitwise-AND of the damage masks between two pixel formats is non-zero, then they share the same buffers.

Remarks

Please notice carefully, as documented above, that certain pixel format properties are not supported in the current generic implementation. The generic implementation is the Microsoft GDI software implementation of OpenGL. Hardware manufacturers may enhance parts of OpenGL, and may support some pixel format properties not supported by the generic implementation.
------
glDrawBuffer:

The glDrawBuffer function specifies which color buffers are to be drawn into.

void glDrawBuffer(
GLenum mode
);

Parameters

mode

Specifies up to four color buffers to be drawn into. Symbolic constants 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, are accepted. (
GL_AUX_BUFFERS is not the upper limit; use glGet to query the number of available aux buffers.) The default value is GL_FRONT for single-buffered contexts, and GL_BACK for double-buffered contexts.

Remarks

When colors are written to the frame buffer, they are written into the color buffers specified by glDrawBuffer. The specifications are as follows:

GL_NONE

No color buffers are written. 

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. 

GL_AUXi

Only auxiliary color buffer i is written.

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.
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.

It is always the case that GL_AUXi = GL_AUX0 + i.
The following functions retrieve information related to the glDrawBuffer function:
glGet with argument GL_DRAW_BUFFER
glGet with argument GL_AUX_BUFFERS


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 called between a call to glBegin and the corresponding call to glEnd.