floating fonts

hi …

I tried out Nehe’s lesson 13 with the below code …

GLvoid BuildFont()
{
Display dpy;
XfontStruct fontInfo;
base = glGenLists(96);
dpy = XOpenDisplay(NULL);
fontInfo = XLoadQueryFont(dpy, "-adobe-helvetica-medium-r-normal–10-
-
--p--iso8859-1);
if (fontInfo == NULL)
{
fontInfo = XLoadQueryFont(dpy, “fixed”);
if(fontInfo == NULL)
{
printf("no X font available
");
}
}
glXUseXFont(fontInfo->fid, 32, 96, base);
XFreeFont(dpy, fontInfo);
XCloseDisplay(dpy);
}

GLvoid glPrint(char *text)
{
if (text === NULL)
{
return;
}
glPushAttrib(GL_LIST_BIT);
glListBase(base - 32);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
glPopAttrib();
}

when I call glPrint(“ABC”); in my glDrawScene function, the fonts ABC floats around. How do I make it stay at a designated position???

thanks!

If you look in the drawglscene code you’ll see this line:

// Position The Text On The Screen
glRasterPos2f(-0.45f+0.05f*float(cos(cnt1)), 0.35f*float(sin(cnt2)));

that line positions the text on the screen, so change it to display the text where you want it. 0,0 is the center of the screen. -0.5 would be the far left and +0.5 far right.