Original Post
this is the code i use to print text it is the code from opengl game programming. i was wondering how to change it so it can take any variable and print it. i want to be able to print the fps and can''t with it currently and i can''t seem to get it to work. please help.
unsigned int listBase;
unsigned int CreateBitmapFont(char *fontName, int fontSize)
{
HFONT hFont; // windows font
unsigned int base;
base = glGenLists(96); // create storage for 96 characters
if (stricmp(fontName, "symbol") == 0)
{
hFont = CreateFont(fontSize, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, SYMBOL_CHARSET,
OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
FF_DONTCARE | DEFAULT_PITCH, fontName);
}
else
{
hFont = CreateFont(fontSize, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
FF_DONTCARE | DEFAULT_PITCH, fontName);
}
if (!hFont)
return 0;
SelectObject(g_hdc, hFont);
wglUseFontBitmaps(g_hdc, 32, 96, base);
return base;
}
void ClearFont(unsigned int base)
{
if (base != 0)
glDeleteLists(base, 96);
}
void PrintString(unsigned int base, char *str)
{
if ((base == 0) || (str == NULL))
return;
glPushAttrib(GL_LIST_BIT);
glListBase(base - 32);
glCallLists(strlen(str), GL_UNSIGNED_BYTE, str);
glPopAttrib();
}