Drawing3d documented Class Library

FeaturesW32.wglUseFontBitmaps Method

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 deviceContext parameter's selected fonts.

[Visual Basic]
<PreserveSig> _
<DllImport(EntryPoint:="wglUseFontBitmaps", CharSet:=CharSet.None, SetLastError:=True, ExactSpelling:=False, PreserveSig:=True, CallingConvention:=CallingConvention.Winapi, BestFitMapping:=False, ThrowOnUnmappableChar:=False, Value:="opengl32.dll")> _
<SuppressUnmanagedCodeSecurity> _
Public Shared Sub wglUseFontBitmaps( _
   ByVal deviceContext As IntPtr, _
   ByVal first As Integer, _
   ByVal count As Integer, _
   ByVal listBase As Integer _
)
[C#]
[PreserveSig]
[DllImport(EntryPoint="wglUseFontBitmaps", CharSet=CharSet.None, SetLastError=True, ExactSpelling=False, PreserveSig=True, CallingConvention=CallingConvention.Winapi, BestFitMapping=False, ThrowOnUnmappableChar=False, Value="opengl32.dll")]
[SuppressUnmanagedCodeSecurity]
public static bool wglUseFontBitmaps(
   IntPtr deviceContext,
   int first,
   int count,
   int listBase
);

Parameters

deviceContext

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 Value

If the function succeeds, the return value is true.

If the function fails, the return value is false. To get extended error information, call GetLastWin32Error.

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 Gl.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 deviceContext. 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 Gl.glBitmap as follows:

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

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

             IntPtr hdc;
             IntPtr hglrc;

             // create a rendering context
             hglrc = Wgl.wglCreateContext(hdc);

             // make it the calling thread's current rendering context
             Wgl.wglMakeCurrent(hdc, hglrc);

             // now we can call OpenGL API

             // make the system font the device context's selected font
             Gdi.SelectObject(hdc, Gdi.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
             Wgl.wglUseFontBitmaps(hdc, 0, 255, 1000);

             // display a string:
             // indicate start of glyph display lists
             GL.glListBase(1000);

             z/ now draw the characters in a string
             GL.glCallLists(24, GL.GL_UNSIGNED_SHORT, "Hello Win32 OpenGL World");
         

See Also

FeaturesW32 Class | Drawing3d.OS.Windows Namespace | wglUseFontOutlines