Jump to content
  • Advertisement
Sign in to follow this  
Paddon

FPS Counter

This topic is 4492 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!