Jump to content
  • Advertisement

Archived

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

griffenjam

queryPerformanceCounter problem

This topic is 6284 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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!