1

I have a function with the following code in it:

GameStateManagementGame.GraphicsDeviceManager.PreferredBackBufferWidth = width;
GameStateManagementGame.GraphicsDeviceManager.PreferredBackBufferHeight = height;
GameStateManagementGame.GraphicsDeviceManager.IsFullScreen = isFullScreen;
GameStateManagementGame.GraphicsDeviceManager.ApplyChanges();

When it's called at application start, if isFullScreen = true, there is very noticeable screen flicker for a second or 2 even if the width and height are the same as the desktop resolution. If I don't have the ApplyChanges(); call this doesn't happen (but the settings do get applied). If I call the function after the game has fully started without the ApplyChanges() call, the settings don't get applied.

Now I can solve this problem by putting something in to skip the ApplyChanges() call at startup but I'd like to know why this is happening.

The only information I've managed to find regarding this problem say that the flicker shouldn't happen if you're using the same resolution as the desktop or have provided overcomplicated and broken workarounds.

So my question is what is the reason for the behaviour described above and what's the best workaround?

rcarrington
  • 1,485
  • 2
  • 12
  • 23

1 Answers1

0

The settings you set on GraphicsDeviceManager are applied in these cases:

  1. If you call ApplyChanges()
  2. If you call ToggleFullScreen()
  3. By Game when Game.Run() is called (it creates the graphics device)

Noteably, modifying any of the settings will not cause those settings to be applied immediately.

The likely reason for your flickering is that you are doing #3 and then immediately doing #1 (you are applying the settings twice in a row).

For initial start-up, you should set the correct settings on the GraphicsDeviceManager instance during your game class's constructor. Then those settings will be correct when Game.Run() is called.

Use ApplyChanges() only when the user changes the settings while the game is running.

Andrew Russell
  • 26,924
  • 7
  • 58
  • 104