Game Development Reference
In-Depth Information
EFFECTS bit tells the dialog box that colour and other effects such
as underline are to be used. We wish to specify colour so we use this
bit.
Having got a user choice for the LOGFONT we need to ensure that this
is the font used by the OpenGL window. First, we create a handle to a font
using CreateFontIndirect . Then we select this into the device context for
the OpenGL window. Now OpenGL knows which font to use when
creating the font outlines. At this stage we are ready to create the display
lists needed to display fonts. The parameters for wglUseFontOutlines
are:
BOOL wglUseFontOutlines(
HDC hdc , // device context of the outline font
DWORD first , // first glyph to be turned into a display
//list
DWORD count , // number of glyphs to be turned into
//display lists
DWORD listBase , // specifies the starting display list
FLOAT deviation , // specifies the maximum chordal deviation
FLOAT extrusion , // extrusion value in the negative z
//direction
int format , // specifies line segments or polygons in
//display lists
LPGLYPHMETRICSFLOAT lpgmf // address of buffer to receive
//glyph metric data
);
Having done some Windows programming, you should by now be
familiar with device contexts, so the hdc parameter should be clear. If we
look at an ANSI table for character values (Table 17.1), you will see that
the first displayable character is 32 (space) and that the standard set of
characters goes up to 126 (~). To display a standard string, we therefore
need to be able to display characters 32 through to 126. When creating
the display lists, we therefore set first to 32 and count to 126 - 31 = 95.
The parameter listbase refers to where in the display lists to store the
result. If this is the first use of display lists then we could set this value to
0. If we have several fonts then each font needs 95 display lists. It is the
responsibility of the scene to make sure that fonts being assigned in this
way use display lists appropriately.
Search Nedrilad ::




Custom Search