Skip to main content
gamedev.net
🔒 Locked

text problem

Started by hello_there 2 replies 400+ views
Original Post
hello_there
hello_there
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(); }
____________How could hell be worse?
ptl
ptl

  
void PrintFps(float fNumFps)
{
char szText[256];
sprintf(szText, "fps : %.2f", fNumFps);
glRasterPos2i(0,0);
glColor3ub(255,255,255);
PrintString(32, szText);
}


suits better ?
hello_there
hello_there
it says sprintf is and undeclared identifier what do i need to include?
____________How could hell be worse?
hello_there
hello_there
ok i know the include now but it just print''s qestions mark and letters. how do i get it to print numbers?
____________How could hell be worse?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.