Advertisement

FPS counter - proper way to use QueryPerformanceCounter?

Started by July 26, 2001 05:51 AM
2 comments, last by kingy 23 years, 6 months ago
Is this a good way to track how many frames per second have occured, assuming that frame is being incremented at each buffer flip and frame and starttime are set reset every second? ///////////////////////////////////////////////////////////////// iTemp=QueryPerformanceCounter(&iGetTickCount); sec=iGetTickCount.LowPart-starttime.LowPart; iTemp=QueryPerformanceFrequency(&lTemp); iFrameRate=(frame*lTemp.LowPart)/sec;
“If you try and please everyone, you won’t please anyone.”
well, QPC return a thousandth of a millisecond. so to get the milliseconds you want to do QueryPerformanceCount*1000. or better yet query the time resolution, then call QueryPerformanceCounter*Resolution. then you need to convert that to a second by multiplying it by 1000.

HHSDrum@yahoo.com
Polarisoft Home Page
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Advertisement
Be careful. Even though the most common frequency of the performance counter is 1,193,182 Hz, this is not guaranteed. I have seen posts claiming it is 100''s of times faster on some systems. It''s safer to do the math out the long way.
Be careful. Even though the most common frequency of the performance counter is 1,193,182 Hz, this is not guaranteed. I have seen posts claiming it is 100''s of times faster on some systems. It''s safer to do the math out the long way.

This topic is closed to new replies.

Advertisement