Before
rendering to a window, one must configure the window according to the rendering
requirements. For example, setting
- The number of colour buffers (single or
double?) and their format
- If a depth buffer is required and its
format
- If a stencil buffer is required
- Version of OpenGL
Once
these parameters are set, they cannot be changed. Reconfiguring will require destroying the
window and creating a new window with the desired format. WGL
uses pixel formats to encapsulate all of this information.
Specifying
the pixel format is done with the function:
wglChoosePixelFormatARB(HDC hdc, const
int *piAttribIList, const
float *pfAttribFList,
UINT nMaxFomats, const
int *piFormats,
UINT *nNumFormats);
piAttribIList is a
null-terminated array of integer attribute pairs
OpenGL
will return a pixel format that is the best match in
iPixelFormatThe
example below finds a pixel format for a double-buffered, hardware accelerated
window with 32 bits colour per pixel, a 24 bit depth buffer, and an 8 bit
stencil buffer.