queryPerformanceCounter problem
I am using QueryPerformanceCounter and am having a strange problem. The counter is only updated when another window has focus. Whats that all about?
griffenjam
Um, well that''s odd. Here''s the code I use...
Magmai Kai Holmlor
- Not For Rent
template <typename T>class HPTimer { public: HPTimer(); T Snap(void); protected: T m_tClockFreq; LARGE_INTEGER m_liPrevSnap; };template <typename T>HPTimer<T>::HPTimer() { LARGE_INTEGER liClockFreq; if(!QueryPerformanceFrequency(&liClockFreq)) //The Query has failed... _ASSERT(0); _ASSERT(liClockFreq.QuadPart); m_tClockFreq = T(liClockFreq.QuadPart); }template <typename T>T HPTimer<T>::Snap() { LARGE_INTEGER liSnap; QueryPerformanceCounter(&liSnap); T tElapsed_sec = T(liSnap.QuadPart - m_liPrevSnap.QuadPart) / m_tClockFreq; m_liPrevSnap = liSnap; return(tElapsed_sec); }//Use it like this:HPTimer<float> m_Timer;float fElaspedTime_sec = m_Timer.Snap();
Magmai Kai Holmlor
- Not For Rent
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement