displaying text on opengl

How do you display simple 2d text on an opengl screen, i want to display the score of a simple game program but dont know how to show the score up on screen in an opengl environment. can someone please help???

Well, the simplest way would be to use glut if you’re familiar with it (though I don’t know for sure if yo can use its functions if you haven’t created a window using glut, but chances are you can). On the other hand there are a few libraries out there that handle the font loading for you. I’m sorry but I can’t remember any names.
As a last resort you could use the operating system’s fonts along with wgl (or xgl) functions to create the glyphs. I don’t think it’s as hard as it sounds. Good luck!

You can build font (windows function CreateFont)
like that :
</font><blockquote><font size=“1” face=“Verdana, Arial”>code:</font><hr /><pre style=“font-size:x-small; font-family: monospace;”>unsigned int CreateBitmapFont(char *fontName, int fontSize)
{
HFONT hFont;
unsigned int base;
g_HDC = GetDC(g_HDC);
base = glGenLists(96);

hFont = CreateFont(fontSize, 0, 0, 0, 600, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_STRING_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;
}
and to print text:

void PrintString(unsigned int base, char *str)
{
if ((base == 0)

thanks alot “DVM” and “saatric” u were spot on.

There’s also a number of tutorials at NeHe’s site that deal with text in OpenGL.
http://nehe.gamedev.net Nehe OpenGL tutorials