Wglusefontbitmaps
Function display text
---- Use wglusefontbitmaps () to convert ASCII characters
Load the display list, and then use the glcalllists () function to display text using the display list sequence. Wglusefontbitmaps has four parameters:
DC, the number of ASCII characters loaded from the first few ASCII characters, the number of ASCII characters in the load list, and the number of starting ASCII characters in the list. Gllistbase () specifies the start point of glcalllists execution
The serial number of the Start List. Glcalllists () contains three parameters: Number of execution list sequences, type of list values, and text to be displayed. Note that if the text to be displayed is a string, it provides
The information is the offset relative to the starting ASCII characters. Therefore, the final displayed ASCII characters are
The list after the offset in glcalllists (). Therefore, the wglusefontbitmaps parameter is loaded from the beginning of the ASCII characters,
The
The serial number of the starting list executed by glcalllists and the text parameters to be displayed in glcalllists () can both affect the final display result. Because the display is ASCII
Therefore, Chinese characters cannot be displayed.
Void ctextview: drawlisttext ()
{
Wglusefontbitmaps (wglgetcurrentdc (), 0,256,100 0 );
Gllistbase (1000 );
Glrasterpos3f (-5.0f, 0.0f, 0.0f );
Glcalllists (20, gl_unsigned
_ Byte, "draw with list text .");
}
wglusefontoutlines
function display 3D text
---- wglusefontoutlines enables OpenGL to display 3D text.
. Its usage is roughly the same as that of the wglusefontbitmaps function, but four parameters are added: interpolation calculation parameters, font depth, display mode, and loading mode cache, and only TrueType fonts can be displayed.
, select the font type before display. The specific function implementation is as follows:
void ctextview: draw3dtext ()
{< br> glyphmetricsfloat agmf [256];
// create display lists for glyphs 0 through 255
// with 0.1 extrusion and default deviation.
// The display list numbering starts at 1000
(it cocould be any number)
wglusefontoutlines (wglgetcurrentdc (),
0,255,100 0, 0.3f, 0.8f, wgl_font_lines, agmf);
// set up transformation to draw the string
gltranslatef (-15.0f, 0.0f, 0.0f );
glscalef (4.0f, 4.0f, 4.0f);
// display a string
gllistbase (1000 );
// indicates the start of display lists for the glyphs
// draw the characters in a string
glcalllists (26, gl_unsigned_byte,
"Draw outline list 3D text. ");
}