# SwapBuffers problem

This topic is 4832 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 youdeltaTime = (temp * interpolation) + (deltaTime * (1 - interpolation));

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

##### 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 on other sites
I'm using QueryPerformanceCounter for my timer. Not sure that theres anything wrong with it.

##### 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

• 10
• 10
• 9
• 48
• 12
• ### Forum Statistics

• Total Topics
631387
• Total Posts
2999712
×