Sign in to follow this  
calidev234

skip jerky walk through (time based movements calculation)

Recommended Posts

I'm having a problem with the walk through movement of the a game loop. It’s a bit jerky or skippy. The movements are based off a time calculation. This problem does not happen on every computer (only a certain few, but on those few it’s consistent). I’ve seen many posts on the latency of the internal clock; but I haven’t seen a way to fix this. Below is a rough idea of the game loop. The app is a SDI app this is run in the app level class overriding the Run() function:
QueryPerformanceCounter((LARGE_INTEGER *) &llCurTime);

fFrameTime=(llCurTime-llLastTime)/(float) llTimerFreq;

llLastTime=llCurTime;

((CMainFrame *) m_pMainWnd)->m_wndView.Game_Run(fFrameTime);

Any ideas? Thank you very much.

Share this post


Link to post
Share on other sites
Another thing to look out for is keeping track of time in seconds as a float. After a machine has been running for a day or two, the precision in the float can't represent the number of seconds and an accurate fraction of a second, and you'll see the time, and thus animations, updating at a much slower rate than the actual frame rate.

Share this post


Link to post
Share on other sites
Laptops often change the CPU frequency for low power consumption. QPC is reading the number of ticks the processor has run. Since the CPU is increasing and decreasing it's clockrate all the time on a laptop, you're getting inconsistant results.

A similar problem exists on dual-core systems where you have different tick counts on each of the two CPUs.

Try another timing option like timeGetTime(). I'm sure DH will have a few other options to throw your way too.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this