Framerate
Does somebody knows how to get the framerate of a program. Do you have to write your own frameratefunction or are there any programs on the internet that can display the fps?
I just use GetTickCount() before the main loop is to start... than GetTickCount() after the loop is done... do some subtraction and this and that and you have a FPS counter... ( each timw the game loops once you increment a counter...)
But GetTickCount() is your key.... there are most accurate System timers but this one is to the millisecond and good ebough for me...
space
But GetTickCount() is your key.... there are most accurate System timers but this one is to the millisecond and good ebough for me...
space
Are there any other ways to do this?
And are there programs on the web who can do this for me?
And are there programs on the web who can do this for me?
GetTickCount() is not accurate. From MSDN:
So, on win9x, the tick count is updated every 55ms, on NT3.1 its 16ms, and on NT3.5 and later, its 10ms.
Edited by - Maximus on February 21, 2001 5:33:17 AM
quote:
Windows NT 3.5 and later The system timer runs at approximately 10ms.
Windows NT 3.1 The system timer runs at approximately 16ms.
Windows 95 and later The system timer runs at approximately 55ms.
So, on win9x, the tick count is updated every 55ms, on NT3.1 its 16ms, and on NT3.5 and later, its 10ms.
Edited by - Maximus on February 21, 2001 5:33:17 AM
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
Pillejunior,
Search the forum. There have been lots of posts about this in the past, including source code.
Search the forum. There have been lots of posts about this in the past, including source code.
February 21, 2001 04:50 AM
It is not too hard to make a fps counter.
First, get the current time before the main loop starts (time_start). That is when you want to start counting the fps. For each frame you display, increase a counter (e.g frames_displayed++). When you want to actually get the result, you get the current time (time_end), calculate how much time you have spent in the loop (time_total = time_end - time_start). Then it is just a matter of dividing the amount of rendered frames (frames_displayed) with the time (time_total). frames_displayed/time_total = frames / second = frames per second. I am still a newbie at windows coding so I don''t really know what the function to get the current time is called, but this is the theory atlest =)
// Poppeman
First, get the current time before the main loop starts (time_start). That is when you want to start counting the fps. For each frame you display, increase a counter (e.g frames_displayed++). When you want to actually get the result, you get the current time (time_end), calculate how much time you have spent in the loop (time_total = time_end - time_start). Then it is just a matter of dividing the amount of rendered frames (frames_displayed) with the time (time_total). frames_displayed/time_total = frames / second = frames per second. I am still a newbie at windows coding so I don''t really know what the function to get the current time is called, but this is the theory atlest =)
// Poppeman
Yes you should use timeGetTime() instead, msdn says that it has a precision of 1ms in Win95 and in WinNT you can specify the precision yourself (using timeBeginPeriod()), but the default is >= 5 ms.
To calculate the fps you can do something like:
Dunno if it works, since this stuff just comes right out my a** but one warning is that the timeGetTime()-timer (as the GetTickCount()-timr) will wrap back to 0 every 49.7 days so you *can* get a strange value every 49.7 days if you don''t take extra precautions...
To calculate the fps you can do something like:
|
Dunno if it works, since this stuff just comes right out my a** but one warning is that the timeGetTime()-timer (as the GetTickCount()-timr) will wrap back to 0 every 49.7 days so you *can* get a strange value every 49.7 days if you don''t take extra precautions...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement