7
\$\begingroup\$

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?

\$\endgroup\$
11
\$\begingroup\$

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."

\$\endgroup\$
  • 1
    \$\begingroup\$ That's more like it. 7k fps ahoy! \$\endgroup\$ – Matthew Scharley Aug 16 '11 at 12:23
  • 1
    \$\begingroup\$ @Mathew, Also note that this will call Update() many more times too. From some preliminary tests, I believe the Update() and Draw() functions are called one after the other in a game loop. So expect 7k Update() calls. \$\endgroup\$ – John McDonald Aug 19 '11 at 18:33
3
\$\begingroup\$

It depends on your video card settings (in Windows). I had the same issue and than I found that my nVidia card has its own vsync settings in control panel where vsync can be set to forced-on mode (application settings will be ignored in this case).

\$\endgroup\$
  • \$\begingroup\$ Possibly an issue, though a quick check of my settings shows vsync set to "Use the 3D application setting". \$\endgroup\$ – Matthew Scharley Aug 16 '11 at 12:05
  • \$\begingroup\$ I even tried setting it to "Force off" and still no help. \$\endgroup\$ – Matthew Scharley Aug 16 '11 at 12:14
  • \$\begingroup\$ I have this issue as well. The 'SynchronizeWithVerticalRetrace' doesn't affect the game even tho the nvidia setting is set to 'Use the 3D application setting'. I have to force it off to work. I wonder if this is an issue with the nVidia driver or if there is a workaround in XNA? I'm using FNA (SDL2) and I've got a nVidia 1080 btw. \$\endgroup\$ – jsmars Feb 14 '17 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.