XNA GraphicsDeviceManager.ApplyChanges()会导致闪烁在应用程序启动时调用 [英] XNA GraphicsDeviceManager.ApplyChanges() causes flicker when called on application start

查看:287
本文介绍了XNA GraphicsDeviceManager.ApplyChanges()会导致闪烁在应用程序启动时调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下code中有一个功能:

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();

当它被称为在应用程序启动,如果isFullScreen = TRUE,有非常明显的屏幕闪烁的第二个或2即使宽度和高度都一样的桌面分辨率。如果我没有ApplyChanges();把这种情况不会发生(但设置也得到应用)。如果我调用该函数之后,比赛已经完全没有了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.

现在我可以把东西跳过ApplyChanges解决这个问题()调用启动时,但我想知道为什么会这样。

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?

推荐答案

你的 GraphicsDeviceManager 设定的设置将被应用在这些情况下:

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

  1. 如果你调用 ApplyChanges()
  2. 如果你调用 ToggleFullScreen()
  3. 游戏 Game.Run()被称为(它创建的图形设备)
  1. If you call ApplyChanges()
  2. If you call ToggleFullScreen()
  3. By Game when Game.Run() is called (it creates the graphics device)

Noteably,修改任何的设置,将不可以导致这些设置将立即生效。

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

为您闪烁可能的原因是,你正在做的#3,然后立即做#1(你所申请的设置连续两次)。

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

对于初始启动,你应该你的游戏类的构造函数中设置的 GraphicsDeviceManager 实例进行正确的设置。然后,这些设置将是正确的,当 Game.Run()之称。

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.

使用 ApplyChanges()仅当用户在游戏运行时更改设置。

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

这篇关于XNA GraphicsDeviceManager.ApplyChanges()会导致闪烁在应用程序启动时调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆