Jump to content
  • Advertisement
Sign in to follow this  
freeworld

problem using QueryPerformanceCounter, my frame time is always zero

This topic is 3494 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'm trying to use QueryPerformanceCounter to calculate the frame time each frame. but I keep getting zero as the result. Under Vista with a Atlon64 X2

LARGE_INTEGER time1;
LARGE_INTEGER time2;
LARGE_INTEGER freq;

// When I create the timer I get the frequency and store the start time in time1
QueryPerformanceFrequency( &freq );
QueryPerformanceCounter( &time1 );

// each frame I get a new count and calculate the time passed as a double
QueryPerformanceCounter( &time2 );

double delta = (time2.QuadPart - time1.QuadPart) / freq.QuadPart;

time1 = time2;
// yet delta always equals zero


Share this post


Link to post
Share on other sites
Advertisement
You are doing an integer division, and it will always be zero if (time2.QuadPart - time1.QuadPart) is less than freq.QuadPart.
Try using (double)freq.QuadPart.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!