Calculating FPS

Started by
3 comments, last by t2sherm 23 years, 9 months ago
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 ô¿ô
t2sherm ô¿ô
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

ICQ: 130925152Email: e.j.folkertsma@student.utwente.nl
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
Thank You!

t2sherm ô¿ô
t2sherm ô¿ô
There''s always the "count the frames, check the time and divide" trick.

This topic is closed to new replies.

Advertisement