Frame Counter

Hi there,

I’ve just started programming in OpenGL and I’m looking at making a frames per second counter

I’ve attempted the following in my Draw routine:


float time, base_time, fps, frames = 0;

time = glutGet(GLUT_ELAPSED_TIME);
frames++;
if((time-base_time) > 1000.0)
{
fps = frames*1000.0/(time-base_time);
std::cout << fps <<std::endl;
base_time = time;
frames = 0;

}


the result of this is a number that is less than one.

Can anybody suggest a way of making a simple frames per second counter?

Cheers

Alex

Perhaps base_time should be a static variable?