Sign in to follow this  

Syncing Update and Draw at a Target Framerate

Recommended Posts


I'd like to be able to have the calls between Update and Draw be synchronized (i.e., have exactly one Update call for every Draw call) AND be called at exactly 60Hz.

In the Initialize function, I tried the following, which didn't help:
this.IsFixedTimeStep = true;
this.TargetElapsedTime = new TimeSpan(0, 0, 0, 0, (int)Math.Round(1000.0f/60.0f));
When I set:
this.IsFixedTimeStep = false
Then, the Update and Draw functions sync, but the framerate is erratic, and certainly not 60 fps. If I then go:
_graphics_device_manager.SynchronizeWithVerticalRetrace = false;
Then, the rate is limited to the screen's refresh rate, which is around 60. This doesn't feel like a solution--limiting the game solely by the monitor's refresh rate. For one thing, it could cause problems; for example, some of the new 3D displays run at 120Hz, which would make the Update and Draw class go twice as fast!

Help please!

I'm using XNA 4.0.


[Edited by - Geometrian on December 6, 2010 12:15:50 AM]

Share this post

Link to post
Share on other sites
read up on these:


if you leave fixedtimestep off xna will attempt 1 Update() to 1 Draw()

120hz is only possible if your frametime is < 8.3 milliseconds
so most 60 fps games will maintain 60 fps even with 120hz refresh

I skip the XNA Update() completely and use an update thread
with a couple of wait handles - this gives 1:1 Update:Draw
plus both methods can take 16.5 milliseconds and I still get 60 fps ...

this approach can be complicated as you need to double buffer any data required in the draw calls ...

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