Advertisement

FPS counter

Started by January 17, 2000 12:55 PM
1 comment, last by ZomeonE 24 years, 10 months ago
How do I implement a FPS (frames per second) counter in my game? I'm using Win32 and DirectDraw. (I don't think that will help, except maybe the win32 thing =) Please give me some code to work on. =) Edited by - ZomeonE on 1/17/00 12:57:15 PM
We went over this one pretty thoroughly last week (or so). Try doing a search in the forum for FPS or frames per second. But basically it''s about counting how many frames occur in a given period of time. Then dividing.
Advertisement
Put this piece of code at the end of your main program loop function:

curGameFrame+=1;
curFPS = curGameFrame/((GetTickCount()-tickZero)/1000);
curSec = (GetTickCount()-tickZero)/1000;

GetTickCount() returns the number of MILLISECONDS that have gone by, so you must divide by 1000 to get seconds.

Here are the inits for the VERY BEGINNING of the program:

double curGameFrame = 0;
double tickZero = GetTickCount();
double curFPS=0;
double curSec=0;

Hope this helps.

This topic is closed to new replies.

Advertisement