0

I'm trying to increase the frame rate of my game from 60FPS to 100 FPS because of reasons. But i can't seem to get it higher than 60 frames. This is the count I'm using. I can slow down the frame rate by setting TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 16);

to a higher value, but settings it lower won't increase the frame rate, according to the counter. Anyone have any idea what's going on?

Subsequent
  • 3
  • 1
  • 3
  • May I ask the reason why you're wanting to increase the frame rate? – test Oct 14 '14 at 18:29
  • Mostly because of animation reasons but also game mechanics reasons. – Subsequent Oct 14 '14 at 18:33
  • 4
    @Subsequent Animation should generally be tied to time, not frame count. Physics can be tied to a fixed frame rate to make it deterministic, but it still shouldn't matter whether you use 60 or 100 fps. – Icy Defiance Oct 14 '14 at 18:40
  • I need to apply updates on certain frames of the animation. – Subsequent Oct 14 '14 at 18:44
  • 1
    You're "frame counting" rather than compensating for time. This will introduce more issues than you are trying to solve. You should use gameTime.ElapsedGameTime to see how much time passed since the last frame. 100FPS is not guaranteed even on a device that is capable of it. – RecursiveCall Oct 14 '14 at 18:53

2 Answers2

4

I found I had to do the following to set the FPS limit free. In your Game class, do the following:

graphics = new GraphicsDeviceManager(this);  // I have this stored as a member variable
graphics.SynchronizeWithVerticalRetrace = false;
IsFixedTimeStep = false;

Note that an unlimited FPS can cause unpredictability in physic engines, and network games. A full discussion of fixed vs variable timesteps can be found here: When should I use a fixed or variable time step?

John McDonald
  • 6,746
  • 2
  • 31
  • 45
  • Oho, apparently i had placed the bools in the loadcontent method which seems to have prevented them from changing the settings. I moved them to the constructor and now it works... |(\ strange that it didn't give me an error though – Subsequent Oct 14 '14 at 19:00
  • @Subsequent See this answer for how GraphicsDeviceManager works: http://stackoverflow.com/a/11287316/165500 (it's about resolution, but it applies to all settings, including vsync). – Andrew Russell Oct 15 '14 at 02:10
  • @Andrew Russell Thank you, very informative. I just started working with C# and XNA a week ago, but i have some prior experience with C and PHP. – Subsequent Oct 15 '14 at 12:25
1

The FPS is capped at 60 because of the default value of true on Game.IsFixedTimeStep. If you set this value to false it should allow your FPS to go to whatever you need it to.

Game.IsFixedTimeStep on MSDN

test
  • 520
  • 4
  • 20
  • I did that as well, but it still says 60FPS on the counter – Subsequent Oct 14 '14 at 18:38
  • 5
    @Subsequent Set GraphicsDeviceManager.SynchronizeWithVerticalRetrace to false as well, and if that doesn't work then your gpu driver might be forcing vsync. You could disable that for your own computer, but you can't guarantee that every computer will do that. Just one of the joys of gamedev right there. – Icy Defiance Oct 14 '14 at 18:49
  • Yeah, that doesn't help either. But would my GPU affect all the programs on my computer then? Because i have another game that runs at 100FPS without problem. – Subsequent Oct 14 '14 at 18:56