PDA

View Full Version : Dynamic Text Using Glut



Tweener
10-01-2002, 12:24 PM
Does anyone know, how I would go about displaying a counter in my window. I want to display a frame rate counter.

Thanks

nexusone
10-01-2002, 05:22 PM
Here is what I do:

// easy way to put text on the screen.
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
glOrtho(-8.0, 8.0, 8.0, -8.0, -1.0, 30.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

// Put view state on screen
glColor3f( 1.0, 1.0, 1.0);
Sprint(-3, 4, "Text");
Note: You can change to perspective mode after writing text...

my text routine:

void Sprint( int x, int y, char *st)
{
int l,i;

l=strlen( st );
glRasterPos2i( x, y);
for( i=0; i < l; i++)
{
// look up glutbitmapcharactor for the other fonts, built in.
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, st[i]);
}

}



Originally posted by Tweener:
Does anyone know, how I would go about displaying a counter in my window. I want to display a frame rate counter.

Thanks

Tweener
10-02-2002, 10:03 PM
Thank you very much, this is so much simpler than the way I was doing it.