Sign in to follow this  
Phy

SwapBuffers problem

Recommended Posts

I recently added time based stuff to my project, but there is a small problem. When vsync is off, everything runs perfectly, but when I turn it on, every once in a while the delta for time will come up with a very small ammount followed by a humoungous ammount the next frame, and the animation jerks for those two frames. Anyone have a solution to this?

Share this post


Link to post
Share on other sites
I haven't experienced such problem but one of the solutions would be to not use time delta directily but interpolate it with the one from last frame. Something like:

float temp = GetRealDeltaTimeForThisFrame();
float interpolation = 0.5; // <- select something in 0.0 - 1.0 range that will work nice for you
deltaTime = (temp * interpolation) + (deltaTime * (1 - interpolation));


This should get rid of some of the spikes in framerate.

Share this post


Link to post
Share on other sites
It might very well be the timer you're using. I experienced the same thing in some of the demos accompanying the GLFW library. It turns out that the timer was causing a problem identical to the one you described. I'm not sure why, or if it was the library, or perhaps just my system, but I think it might have had to do with the precision of the timer available.

Cheers!

Share this post


Link to post
Share on other sites
QueryPerformanceCounter doesnt work correctly with a lot of laptop and also with the new desktop cpus that are coming out (ones that throtlle the cpu speed)
but thats not the problem
perhaps look into this method
http://www.mindcontrol.org/~hplus/graphics/game_loop.html
http://www.flipcode.com/cgi-bin/fcarticles.cgi?show=63823

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