• Advertisement

Archived

This topic is now archived and is closed to further replies.

queryPerformanceCounter problem

This topic is 6012 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Um, well that''s odd. Here''s the code I use...

  
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

Share this post


Link to post
Share on other sites
Yeah, that''s very similar to what I am doing.
Is there a problem with the counter on Windows 2000?

griffenjam

Share this post


Link to post
Share on other sites

  • Advertisement