XNA GraphicsDeviceManager.ApplyChanges() causes flicker when called on application start

后端 未结 1 1615
猫巷女王i
猫巷女王i 2021-01-23 15:54

I have a function with the following code in it:

GameStateManagementGame.GraphicsDeviceManager.PreferredBackBufferWidth = width;
GameStateManagementGame.Graphics         


        
相关标签:
1条回答
  • 2021-01-23 16:15

    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.

    0 讨论(0)
提交回复
热议问题