Frames Per Second
I was wondering how I can measure frames per second. I have some code to get time and I was wondering how I can use it to measure FPS.
Note: GetTickCount ( ); returns number of milliseconds since computer was started
Here is the code:
// Initializes Tick1, Tick2, and DTick
Tick1 = GetTickCount ( );
Tick2 = GetTickCount ( );
DTick = (float)((Tick2 - Tick1) / 30.0);
In the main loop of my program I have:
// Update time
Tick1 = Tick2;
Tick2 = GetTickCount ( );
DTick = (float)((Tick2 - Tick1) / 30.0);
Any help would be greatly appreciated.
Zack
Edited by - zeotron on 8/10/00 1:31:53 AM
Edited by - zeotron on 8/10/00 1:32:35 AM
A moment enjoyed is not wasted. -Gamers.com
This is what you do: Save the Tick count before the update and after. Then take their difference and devide it into 1000.
For EX:
This code will give you the actuall FPS currentaly and not the average FPS that saving the frame count and total time elapsed would give you.
------------------------------
"My sword is like a menacing cloud, but instead of rain, blood will pour in its path." - Sehabeddin, Turkish Military Commander 1438.
For EX:
TicksAtBeginning = GetTickCount();// update the game and draw the new frame...TicksAtEnd = GetTickCount();FPS = 1000 / (TicksAtEnd - TicksAtBeginning);
This code will give you the actuall FPS currentaly and not the average FPS that saving the frame count and total time elapsed would give you.
------------------------------
"My sword is like a menacing cloud, but instead of rain, blood will pour in its path." - Sehabeddin, Turkish Military Commander 1438.
------------------------------"My sword is like a menacing cloud, but instead of rain, blood will pour in its path." - Sehabeddin, Turkish Military Commander 1438.
I thought that was how to do it, but I just wanted to makre sure.
Thanks,
Zack
Thanks,
Zack
A moment enjoyed is not wasted. -Gamers.com
Whats the advantage/difference (if any) of using GetTickCount over timeGetTime() ??
- Keith (new to OpenGL programming)
- Keith (new to OpenGL programming)
Of course you would want to use a bit shift instead of division Dont want the FPS counter to hurt performance now do we?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement