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-
if (fontInfo == NULL)
fontInfo = XLoadQueryFont(dpy, “fixed”);
if(fontInfo == NULL)
printf("no X font available
glXUseXFont(fontInfo->fid, 32, 96, base);
XFreeFont(dpy, fontInfo);

GLvoid glPrint(char *text)
if (text === NULL)
glListBase(base - 32);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);

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


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.