【发布时间】:2015-01-15 22:39:26
【问题描述】:
我使用 MonoGame(3.2 版,撰写本文时的最后官方版本)创建了一个简单的测试应用,但我无法让应用全屏显示。
我在别处找到了这段代码:
protected override void Initialize()
{
graphics.IsFullScreen = true;
graphics.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width;
graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
graphics.ApplyChanges();
Window.IsBorderless = true;
Window.Position = new Point(0, 0);
base.Initialize();
}
但问题是GraphicsDevice.DisplayMode 总是返回800x600 的屏幕尺寸。此外,GraphicsAdapter.Adapters 集合仅包含一个适配器,具有一个支持的显示模式 (800x600)。
这可能是什么问题?我当前的分辨率是 1920x1080,如果我将两台显示器连接为扩展桌面(这是我通常的设置),我会得到相同的结果。
更新
最后我只是简单地添加了对System.Windows.Forms 的引用并使用了:
graphics.IsFullScreen = true;
graphics.PreferredBackBufferWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
graphics.PreferredBackBufferHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
graphics.ApplyChanges();
我仍然想知道为什么 MonoGame 没有正确检测到任何适配器/屏幕。
更新 2 如this answer 所述,该问题已在非官方版本中修复(在撰写本文时)。
【问题讨论】:
-
尝试将该代码移动到
Game构造函数的末尾 -
@Vlad:这行不通,因为
GraphicsDevice在 ctor 内部为空(至少在 MonoGame 中,我认为这在 XNA 中的行为不同)。 -
我刚刚在
base.Initialize()之后设置了graphics.IsFullScreen = true和nothing else,它按预期工作。您正在使用 winforms 来解决这个问题,所以我猜您使用的是 Windows,而不是 Linux/Mac。你介意确认哪个版本吗?我去搭建一个虚拟机看看 -
@Joe:谢谢!是的,它是 Windows 8.1(64 位,如果重要的话)。嗯,现在我也发现了同样的问题here。我会检查一下,如果它有效,我会重复投票。
-
@Joe:好的,构建最新的开发分支解决了这个问题。 commit linked in the other answer 修复了
GraphicsAdapter中的问题,投票以重复关闭。
标签: c# fullscreen monogame