• Advertisement

Archived

This topic is now archived and is closed to further replies.

help with framerate

This topic is 5236 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering what exactly framerate was especially in respect to an isographic 2d map. How do you determine frame rate.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
There''s a tutorial on www.gametutorials.com about displaying the framerate in OpenGL.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement