Jump to content
  • Advertisement

Archived

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

t2sherm

Calculating FPS

This topic is 6696 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 how i could calculate frames per second in a game i am making. I have a way to do it in VB, but i need one for C++. I was going to use the CTimer.GetSecond(), but to use that i have to include afx.h, and when i do that i get linking errors, so is there a different function i could use like VB''s Timer? Here is the one from a different game done in VB ''Calculate the frame rate dim i as integer, fps as integer, tLast as integer If i = 30 Then If tLast <> 0 Then fps = 30 / (Timer - tLast) tLast = Timer i = 0 End If i = i + 1 ''(then write out variable fps) t2sherm ô¿ô

Share this post


Link to post
Share on other sites
Advertisement
If you are still interested in how to calculate it in C++, please mail me at mitolah@hotmail.com and I''ll tell you how to do it...

I will not say it here... it takes too much code!!

Greetings Dark

Share this post


Link to post
Share on other sites
How about this (taken from D3Dframe of the DX7 SDK):

static DWORD dwLastTime = 0;
static float fFPS = 0;
static DWORD dwFrames = 0;

// Keep track of the time lapse and frame count
DWORD dwTime = timeGetTime();
dwFrames++;

// Update the frame rate once per second
DWORD dwTimeDiff = dwTime - dwLastTime;
if (dwTimeDiff > 1000) {
fFPS = (float)dwFrames / dwTimeDiff * 1000;
dwLastTime = dwTime;
dwFrames = 0;
}

// Print fFPS to show FPS
...


ArgoN

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!