Jump to content
  • Advertisement
Sign in to follow this  
Phy

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.

If you intended to correct an error in the post then please contact us.

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

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