PDA

View Full Version : Fps counter using OpenGL?



05-26-2002, 05:09 AM
How do i make a simple Frames per second counter using OpenGL for Visual c++ 6.0???

an example would be much appreciated.

Bob
05-26-2002, 06:50 AM
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.

Leyder Dylan
05-26-2002, 11:24 AM
Hi,

Check on my site, I've a little example who use a fps counter.
http://ibelgique.ifrance.com/Slug-Production/

svc2211
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

svc2211
05-27-2002, 10:33 AM
they are all for VC++

05-27-2002, 10:54 AM
Thanks for all your replies

chicho
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;
frames=0;
}

The variable "frames" is a counter of frames, and It's to be incremented in each frame (Usually in Draw function).