Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Dynamic Text Using Glut

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    11

    Dynamic Text Using Glut

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

    Thanks

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,096

    Re: Dynamic Text Using Glut

    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

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    11

    Re: Dynamic Text Using Glut

    Thank you very much, this is so much simpler than the way I was doing it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •