Jump to content
  • Advertisement
Sign in to follow this  

problem using QueryPerformanceCounter, my frame time is always zero

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


// 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
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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!