Reputation: 41
I recently changed my game to run at 144 fps rather than the default 60 fps but it always stays at 143 fps. It's not a big deal since you can't tell the difference without an fps counting program but I'd still like to know why this happens and how to fix it. Here's my code.
protected override void Initialize()
{
TargetElapsedTime = TimeSpan.FromSeconds(1.0 / 144.0f);
IsFixedTimeStep = true;
graphics.SynchronizeWithVerticalRetrace = false;
base.Initialize();
}
Upvotes: 1
Views: 556
Reputation: 41
After hours of tinkering with code I've found this to be the best combination of settings. I left VSync on but disabled "FixedTimeStep". The game now runs fairly consistently at 144fps unless it's on a standard monitor in which case it runs at 60fps. This means I'll have to change a few animations to be time based rather than frame based but I was thinking of doing that anyways.
protected override void Initialize()
{
TargetElapsedTime = TimeSpan.FromSeconds(1.0 / 144.0f);
IsFixedTimeStep = false;
base.Initialize();
}
Upvotes: -1
Reputation: 421
After calling Game.Update
and Game.Draw
, MonoGame spends any excess time by calling the system sleep function (Thread.Sleep()
to be exact). The sleep call has millisecond accuracy at best, and may be worse depending on various factors. The difference between 143 and 144 FPS is about 0.05 milliseconds per frame - way less than the system timer resolution.
As far as I know, there is little you can do (apart from trying to enable VSync on a 144 FPS display). The difference is really minimal and subject to measurement errors. I wouldn't bother trying to fix it.
Upvotes: 2