1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
PGLFONT createGLFont(HDC hDC, const std::string& typeface, int height, int weight, DWORD italic)
{
PGLFONT font;
HFONT fontid;
int charset;
font = new GLFONT;
if(!(font->base= glGenLists(256)))
{
delete font;
return NULL;
}
charset = ANSI_CHARSET;
fontid = CreateFont(height,0,0,0,weight, italic, FALSE, FALSE,
charset, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
DRAFT_QUALITY, DEFAULT_PITCH, typeface.c_str());
SelectObject(hDC, fontid);
wglUseFontBitmaps(hDC, 0, 256, font->base);
GetCharWidth32(hDC, 0, 255, font->widths);
font->height = height;
return font;
}
void printGLFont(PGLFONT font, const std::string& text)
{
if (font == NULL || text.size() == 0)
return;
glPushAttrib(GL_LIST_BIT);
glListBase(font->base);
glCallLists(text.size(), GL_UNSIGNED_BYTE, text.c_str());
glPopAttrib();
return;
}
void deleteGLFont(PGLFONT font)
{
if(font == NULL) return;
glDeleteLists(font->base, 256);
delete font;
return;
}
|