SIGGRAPH '97
Course 24: OpenGL and Window System Integration
OpenGL and Win32
WGL Reference
WGL (pronounced "wiggle") is the glue that binds OpenGL and the Win32
API together.
Rendering Context Functions
Function | Description |
wglCreateContext | Creates a new
rendering context. |
wglMakeCurrent | Sets a
thread's current rendering context. |
wglGetCurrentContext | Obtains a
handle to a thread's current rendering context. |
wglGetCurrentDC | Obtains a handle
to the device context associated with a thread's current rendering
context.
|
wglDeleteContext | Deletes a rendering
context. |
See the source code referenced in previous sections for examples of
the use of each of these functions.
Font and Text functions
Function | Description |
wglUseFontBitmaps |
Creates a set of character bitmap display lists. Characters come from a specified device context's current font. Characters are specified as a consecutive run within the font's glyph set. |
wglUseFontOutlines | Creates a set of
display lists, based on the glyphs of the currently selected outline
font of a device context, for use with the current rendering
context. The display lists are used to draw 3-D characters of TrueType
fonts. |
example from Microsoft Developer Studio topic
wglUseFontBitmaps
HDC hdc;
HGLRC hglrc;
// create a rendering context
hglrc = wglCreateContext (hdc);
// make it the calling thread's current rendering context
wglMakeCurrent (hdc, hglrc);
// now we can call OpenGL API
// make the system font the device context's selected font
SelectObject (hdc, GetStockObject (SYSTEM_FONT));
// create the bitmap display lists
// we're making images of glyphs 0 thru 255
// the display list numbering starts at 1000, an arbitrary choice
wglUseFontBitmaps (hdc, 0, 255, 1000);
// display a string:
// indicate start of glyph display lists
glListBase (1000);
// now draw the characters in a string
glCallLists (24, GL_UNSIGNED_BYTE, "Hello Win32 OpenGL World");
example from Microsoft Developer Studio topic
wglUseFontOutlines
HDC hdc; // A TrueType font has already been selected
HGLRC hglrc;
GLYPHMETRICSFLOAT agmf[256];
// Make hglrc the calling thread's current rendering context
wglMakeCurrent(hdc, hglrc);
// create display lists for glyphs 0 through 255 with 0.1 extrusion
// and default deviation. The display list numbering starts at 1000
// (it could be any number)
wglUseFontOutlines(hdc, 0, 255, 1000, 0.0f, 0.1f,
WGL_FONT_POLYGONS, &agmf);
// Set up transformation to draw the string
glLoadIdentity();
glTranslate(0.0f, 0.0f, -5.0f)
glScalef(2.0f, 2.0f, 2.0f);
// Display a string
glListBase(1000); // Indicates the start of display lists for the glyphs
// Draw the characters in a string
glCallLists(24, GL_UNSIGNED_BYTE, "Hello Win32 OpenGL World.");
Overlay, Underlay and Main Plane functions
Function | Description |
wglCopyContext |
Copies selected groups of rendering states from one OpenGL rendering
context to another. |
wglCreateLayerContext |
Creates a new OpenGL rendering context for drawing to a specified
layer plane on a device context. |
wglDescribeLayerPlane | Obtains information
about the layer planes of a given pixel format. |
wglGetLayerPaletteEntries | Retrieves the
palette entries from a given color-index layer plane for a specified
device context. |
wglRealizeLayerPalette | Maps palette entries
from a given color-index layer plane into the physical palette or
initializes the palette of an RGBA layer plane. |
wglSetLayerPaletteEntries | Sets the palette
entries in a given color-index layer plane for a specified device
context. |
wglSwapLayerBuffers | Swaps the front and
back buffers in the overlay, underlay, and main planes of the window
referenced by a specified device context.
|
See the overlay.c program for examples of how to use the
functions above.
Miscellaneous Functions
Function | Description |
wglShareLists | Enables a rendering context
to share the display-list space of another rendering context. |
wglGetProcAddress | Returns the address of an
OpenGL extension function for use with the current OpenGL rendering
context. |