another fps question

I am using this function (from to get the fps in my glut program. Can somebody tell me that it works ok because I get a constant rate of about 20, but about 40-45 when I move the paddle(It is the beginning of a breakout clone)???

It is being called immediately after the call to glutSwapBuffers().

void CalculateFrameRate()
	static float framesPerSecond    = 0.0f;
	static float lastTime			= 0.0f;
	static char strFrameRate[50] = {0};	
	float currentTime = GetTickCount() * 0.001f;				
	// Increase the frame counter
	if( currentTime - lastTime > 1.0f )
		lastTime = currentTime;
		cout << framesPerSecond << endl;
		// Reset the frames per second
		framesPerSecond = 0;

Here is the timer function in case its relevant:

void timer( int i )
	ball.moveBall( );
	glutPostRedisplay( );
	glutTimerFunc( 10, timer, 1 );		//resets the timer function

I have noticed that too with glut programs that display fps. Whenever a key is pressed, the fps jumps up as long as the key is held down. Release and the fps go back down. Not sure on what the prob with glut is

You don’t show the code that calls CalculateFrameRate. My suspicion is that it is called every time you get input in addition to every time the screen is drawn.

This is the code that calls CalcualteFrameRate(…). It is registered as the callback function.

void renderScene( )
	glColor3f( 1.0f, 0.0f, 0.0f );

	glLoadIdentity( );

	ball.drawBall( );
	paddle.drawPaddle( );

	glutSwapBuffers( );
	CalculateFrameRate( );

Thanks for the help