Jump to content
  • Advertisement


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


Calculating Framerate

This topic is 6010 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 am tring to calculate the framerate for my game and in my current system, I see how long it takes to complete 1 gameloop in milliseconds. I then devide 1 by that number and multiply by 1000. I dont think this is right because my results are very low. In the DirectX SDK examples the framerate can be a few hundred frame a second. I am rendering a rather simple scene. the code I use: Timer.ThisTime = timeGetTime(); Timer.DiffTime = Timer.ThisTime - Timer.LastTime; Timer.LastTime = Timer.ThisTime; then Framerate = 1000 * (1 / Timer.DiffTime) Go on an Intense Rampage

Share this post

Link to post
Share on other sites
Let''s say your program is running at 40fps- your diff is going to be 25 (milliseconds). By your math:
Framerate = 1000 * (1 / Timer.DiffTime)
Framerate = 1000 * (1 / 25)
Framerate = 1000 * (1 / 25)
Framerate = 1000 * (.04)
Framerate = 40
So, this appears to be correct.
If you have any doubts, put in a counter. In render():

MsCount += Timer.DiffTime;
if(MsCount >= 1000) { Framerate2 = fps; MsCount = fps = 0; };

I think you''ll find Framerate & Framerate2 and are pretty close (fr2 is a 1-sec average). They did in my programming.

---email--- Tok ----surf----
~The Feature Creep of the Family~

Share this post

Link to post
Share on other sites
If your number is between 0 and 90 max, but what you want (I have never used the DirectX SDK) some rediculous number such as 2000fps, its is because it is a BS FPS. The REAL FPS is probably what you are recieveing. This is limited by your monitor refresh rate. If you are flickering on 60hz, then you are probably using the standard refresh rate (windows control panel) of 60hz.

Change this to see if you are using the real fps or the BS fps.

Beer - the love catalyst
good ol'' homepage

Share this post

Link to post
Share on other sites
According to the calculations you''re implying, the frame-rate number should be okay, since a frame-rate is a frequency, which is the inverse of a period of time:

F = 1/T

and if your period of time is given in millisecs, it makes sense to multiply it by 1000 (conversion from milliseconds to seconds).

You should, however, read a note I dropped to ''peaceman'' on his post: ''frame rate differences'' (I think that''s the name of it), to learn some more.


when all else fails..

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!