Skip to main content
gamedev.net
🔒 Locked

syncing a program with the system clock

Started by alecmoody Oct 9, 2003 at 10:05 PM 6 replies 550+ views
Original Post
alecmoody
alecmoody
Does anyone have an article or any information on how this is done? Any resources would be great.
Teric
Teric
Try the QueryPerformanceCounter() function.
I am always open to feedback, positive or negative...
alecmoody
alecmoody
Im looking for more of an article describing the concept than any specific function.
alecmoody
alecmoody
Thanks, thats perfect.
bucheron
bucheron
Btw, on Windows with QueryPerformance, is there a way to avoid the timing to "block" during a very short period (this often happens when the system swaps during maybe 1/10 of sec). I sometimes have jerky motion and I wanted to know if you have the same problems. I update the timer once at the beginning of the main loop and stores the result in float format. Then I use the delta_time between two frames to update the velocity, position,...

[edited by - bucheron on October 12, 2003 4:44:01 AM]
juuso
juuso
Have you tried using an average for your dtime? It smoothes out most small jerks.

In pseudocode

delta_time = CurrentTime - Previoustime;

smooth_time = smooth_time*20 + delta_time;
smooth_time = smooth_time / 21;

UpdatePhysics(smooth_time);
bucheron
bucheron
Thx Juuso, I will give it a try

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.