View Full Version : Fps counter using OpenGL?
How do i make a simple Frames per second counter using OpenGL for Visual c++ 6.0???
an example would be much appreciated.
You can't make a frame rate counter with OpenGL, cause OpenGL doesn't provide any timer functions. Use some system timers instead, like timeGetTime or QueryPerformanceCounter. Look in MSDN for more details on how to use them.
There's a few ways to calculate the FPS, all based on the same formula. FPS = frames / time, where frames is the number of frames rendered, and time is the time taken to render them. For example, measure the time taken to render one or ten (or as many as you like) frames, or count the number of frames rendered in a second.
05-26-2002, 11:24 AM
Check on my site, I've a little example who use a fps counter.
05-27-2002, 10:32 AM
go to http://www.gametutorials.com they have good tutorails for opengl and one ids the fps counter check it out
05-27-2002, 10:33 AM
they are all for VC++
Thanks for all your replies
05-28-2002, 03:50 AM
If you use Glut libraires it's very easy, you have to take the time with the function "glutGet (GLUT_ELAPSED_TIME)" and make a substraction with the previous value:
time = glutGet(GLUT_ELAPSED_TIME);
if ((time - base_time) > 1000.0)
fps=frames*1000.0/(time - base_time);
base_time = time;
The variable "frames" is a counter of frames, and It's to be incremented in each frame (Usually in Draw function).
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.