🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
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
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.
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?
Read the boards and this is what I came up with.
queryperformancecounter (if spelled right)
- Fastest and most accurate
TimeGetTime
- Second fastest and accurate
GetTickCount
- not so fast and not so accurate but it works without including the winmm library.
- Keith
queryperformancecounter (if spelled right)
- Fastest and most accurate
TimeGetTime
- Second fastest and accurate
GetTickCount
- not so fast and not so accurate but it works without including the winmm library.
- Keith
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement