FPS Counter

Started by
1 comment, last by Limitz 17 years, 10 months ago
I have implemented a Frames Per Second Calculator in my recent project but it is currently stationary while my camera is completly user controlled. I would like to have this implemented such that the stats i.e FPS, and X,Y,Z coords are always located in the same spot on the frame no matter where the camera is pointing. I was wondering if anyone knew a good algorithm for implementing this or where I may find a tutorial on the subject. I am using openGL and Glut if that makes a difference. Thank You
Jeff PaddonUndergraudate Research AssistantPhysics DepartmentSaint Francis Xavier University
Advertisement
I think you're looking for a HUD.. these elements shouldn't exist in the 3D world.

Here you'll find an example on how to draw text on the screen.

Hope this helps

Eric
Hi,

In OpenGL this can be done by setting the projection matrix to an Orthogonal (2d) one, gluOrtho2D. It sets the z range to -1,1 so be sure to give your text 2d coordinates (z=0). You should also push,reset,pop the modelview matrix because this will probably be altered by gluLookAt of glFrustum.
The following code should be called in the render routine (not in initialization or whatever)

this is the code i use:

//go 2d ortho
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0,800,0,600); //in glu.h

//get a clean modelview matrix
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

//use glRasterPos to set a coordinate and draw text, GLUT may have some
//alternate utility func for that.

//pop modelview and projection matrix for perspective use
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

glMatrixMode(GL_PROJECTION);
glPopMatrix();

Good Luck & Greetings;

This topic is closed to new replies.

Advertisement