Frames

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

Recommended Posts

How do I detect how many frames per second the game user has got, I noticed that the DirectX examples use it but I dont know how to.

Share on other sites
There are quite a few ways.

1) calculate the time (in seconds) between each frame, then invert it. Cons-Requires good timer, hard to read when it flickers thew frames so fast.

2)count each frame, then figure out how many have been drawn after each second/tenth of a second/any amount of time. Pros-Easy to use, fairly accurate, less accurate timer is still OK.

I'm sure there are other ways and permutations of these, but these are the two I see most often. I prefer the second, it is easier, and makes much more sense to me. You should try both methods (plus anyone elses suggestions) and figure out which one works best for you.

Share on other sites
yeah but how do you find out how many frames you have done so far?

Share on other sites
Quote:
 Original post by frupertyeah but how do you find out how many frames you have done so far?

depending on what language you are using, I am sure you have access to some sort of semi decent timer. For the 2nd choice, it should have a latency of no more than around 10 ms to be very accurate. In windows, timeGetTime, GetTickCount, and Environment.GetTickCount (.NET only) should get the job done. Hre is some basic code:

//Run this stuff every frameif (currentTime - lastTimeCheck >= 1000) // <--assuming the resolution is in ms{    fps = frames;    frames = 0;    lastTimeCheck = currentTime;}frames++;

substitute "currentTime" with whatever function you plan on using (Check google for tutorials on them). Run that bit of code every frame (usually in your game loop, or in the OnPaint override if you are using .NET), and it will store the current Frames per second in the variable fps, which you can do whatever with.

[Edited by - Sr_Guapo on September 8, 2004 5:56:56 PM]

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 22
• 13
• 14
• 45