wglUseFontBitmaps

The wglUseFontBitmaps function creates a set of bitmap display lists for use in the current OpenGL rendering context. The set of bitmap display lists is based on the glyphs in the currently selected font in the device context. You can then use bitmaps to draw characters in an OpenGL image.

The wglUseFontBitmaps function creates count display lists, one for each of a run of count glyphs that begins with the first glyph in the hdc parameter's selected fonts.

BOOL wglUseFontBitmaps(
  HDC  hdc,         // device context whose font will be used
  DWORD  first,     // glyph that is the first of a run of glyphs to 
                    // be turned into bitmap display lists
  DWORD  count,     // number of glyphs to turn into bitmap display 
                    // lists
  DWORD  listBase   // specifies starting display list
);

Parameters

hdc
Specifies the device context whose currently selected font will be used to form the glyph bitmap display lists in the current OpenGL rendering context.
first
Specifies the first glyph in the run of glyphs that will be used to form glyph bitmap display lists.
count
Specifies the number of glyphs in the run of glyphs that will be used to form glyph bitmap display lists. The function creates count display lists, one for each glyph in the run.
listBase
Specifies a starting display list.

Return Values

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE. To get extended error information, call GetLastError.

Remarks

The wglUseFontBitmaps function defines count display lists in the current OpenGL rendering context. Each display list has an identifying number, starting at listBase. Each display list consists of a single call to glBitmap. The definition of bitmap listBase+i is taken from the glyph first+i of the font currently selected in the device context specified by hdc. If a glyph is not defined, then the function defines an empty display list for it.

The wglUseFontBitmaps function creates bitmap text in the plane of the screen. It enables the labeling of objects in OpenGL.

In the current version of Microsoft's implementation of OpenGL in Windows NT and Windows 95, you cannot make GDI calls to a device context that has a double-buffered pixel format. Therefore, you cannot use the GDI fonts and text functions with such device contexts. You can use the wglUseFontBitmaps function to circumvent this limitation and draw text in a double-buffered device context.

The function determines the parameters of each call to glBitmap as follows.

glBitmap Parameter Meaning
width The width of the glyph's bitmap, as returned in the gmBlackBoxX member of the glyph's GLYPHMETRICS structure.
height The height of the glyph's bitmap, as returned in the gmBlackBoxY member of the glyph's GLYPHMETRICS structure.
xorig The x offset of the glyph's origin, as returned in the gmptGlyphOrigin.x member of the glyph's GLYPHMETRICS structure.
yorig The y offset of the glyph's origin, as returned in the gmptGlyphOrigin.y member of the glyph's GLYPHMETRICS structure.
xmove The horizontal distance to the origin of the next character cell, as returned in the gmCellIncX member of the glyph's GLYPHMETRICS structure.
ymove The vertical distance to the origin of the next character cell as returned in the gmCellIncY member of the glyph's GLYPHMETRICS structure.
bitmap The bitmap for the glyph, as returned by GetGlyphOutline with uFormat equal to 1.

The following code example shows how to use wglUseFontBitmaps to draw some text:

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"); 

Requirements

  Windows NT/2000: Requires Windows NT 3.5 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in wingdi.h.
  Import Library: Use opengl32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also

OpenGL on Windows NT, Windows 2000, and Windows 95/98, WGL Functions, GetGlyphOutline, glBitmap, glCallLists, glListBase, GLYPHMETRICS, wglUseFontOutlines


  

Community Additions

Show: