Jump to content
  • Advertisement
Sign in to follow this  
bellicose

How To Determine FPS In OpenGL

This topic is 4518 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 am working through NeHe's OpenGL tutorials and have arrived at the tutorial on how to display text (Lesson 13) and I am trying to find out how to display the current FPS. Is there a command to call upon to allow me to print it to the screen?

Share this post


Link to post
Share on other sites
Advertisement
Compute it as seconds per frame, rather than frames per second. It is more useful.

You display it the same way you would display any other text in opengl. Create your strings either sprintf family in C or the stringstream (or some other) class in c++. Use the wglUseFontBitmaps() and glDisplayLists() functions to help render them. I could give a simple class that would do it all for you, but looking up how to use them properly will teach you much more than a simple code sample would.

Share this post


Link to post
Share on other sites
You can use GLUT to print text in an OpenGL window. I used it in my SDL and QTOpenGL projects, the font library in GLUT is pretty stand-alone and it's very easy to use. There are probably lots of better font libraries, but that one is very small and perfect for a debug font.

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!