help with framerate

Started by
1 comment, last by Benzy54 20 years, 6 months ago
I was wondering what exactly framerate was especially in respect to an isographic 2d map. How do you determine frame rate.
Advertisement
There''s a tutorial on www.gametutorials.com about displaying the framerate in OpenGL.
Framerate is the number of frames rendered per unit of time. Every time you draw a frame, you increment a count of the number of frames drawn. Then you let some new quantity equal the number of frames drawn divided by how long the program has been running for.

However, if you do it that way, you only get the average framerate over the entire run of the program, which means it is generally slower than the instantaneous framerate because it includes the time spent loading resources. For a more practical way to determine framerate, you should reset your counters every three seconds or so. That way, you can get information about framerate drops or increases when they actually happen.

Here''s an example with C++ code:

// Updates the timer.void UpdateTimer(void){	static DWORD previousTime = GetTickCount();	static DWORD recentTime = 0.0;	static int recentFrames = 0;		elapsedTime = GetTickCount() - previousTime;	timeRatio = Ratio((float)elapsedTime, timeRate);	previousTime = GetTickCount();	recentTime += (double)elapsedTime;	totalTime += (elapsedTime / 1000.0);			// Reset the frames-per-second display every three seconds.		if(recentTime > 3000.0)		{			currentFPS = recentFrames / (recentTime / 1000.0);			recentTime = 0.0;			recentFrames = 0.0;		}			recentFrames++;	totalFrames++;}


"Last time, I asked: ''What does mathematics mean to you?'' And some people answered: ''The manipulation of numbers, the manipulation of structures.'' And if I had asked what music means to you, would you have answered: ''The manipulation of notes?''" - S. Lang
You don't need to vote for the "lesser of two evils"! Learn about Instant Runoff Voting, the simple cure for a broken democracy!

This topic is closed to new replies.

Advertisement