MonoGame - GraphicsAdapter.DefaultAdapter.Current.Width/Height 在 MacBook Pro 2015 上报告错误值

MonoGame - GraphicsAdapter.DefaultAdapter.Current.Width/Height Reports wrong value on MacBook Pro 2015

我正在尝试使用 MonoDevelop/C# 获取用户显示器的分辨率。

在我测试过的大多数机器上,它都能完美运行 - 除了这台 Macbook Pro。

原始分辨率为 2880x1800,但 DefaultAdapter 宽度报告为 1280x1024。我可以手动设置图形设备PreferredBufferHeightPreferredBufferWidth,没问题

是否有更可靠的方法来 return 显示器的分辨率?

您可以在您的项目中引用 System.Windows.Forms,并使用 Screen.PrimaryScreen.Bounds 找出用户屏幕的分辨率。

如果您还没有尝试过使用 GraphicsDevice.DisplayMode.WidthGraphicsDevice.DisplayMode.Height,您应该先尝试一下。

另一种方式是 GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.WidthGraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height