Wednesday, December 9, 2015

xna 4.0 - How do I enable higher FPS in XNA 4.0?


I created a FpsCounter DrawableGameComponent (linked to code, it's longish). It works great: It displays 60.0 fps normally. If I artificially slow down the game loop, it drops.


My 'game' at the moment is a single keyboard-controlled sprite, so it should be possible to render more frequently than 60 frames a second.



I figured turning off vertical synchronization would increase the FPS cap:


public Game1()
{
_graphics = new GraphicsDeviceManager(this)
{
PreferredBackBufferWidth = WindowWidth,
PreferredBackBufferHeight = WindowHeight,
SynchronizeWithVerticalRetrace = false,
};
_graphics.ApplyChanges();

Content.RootDirectory = "Content";
}

However, even though the above code seems like it should turn off vsync, it doesn't seem to be. Is there something wrong with my constructor, or perhaps my FPS calculations? Or is there something else that may be limiting the frame count?



Answer



if Game.IsFixedTimeStep is true the update method will be called every 1/60 seconds


http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.isfixedtimestep.aspx


"The default value for IsFixedTimeStep is true."


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...