如何在XNA / Monogame中获得显示分辨率? 我在我的显示器上尝试了这些(1600x900):
下面给我800,600
//1.
GraphicsDevice.DisplayMode.Width
GraphicsDevice.DisplayMode.Height
//2.
GraphicsDeviceManager graphics = new GraphicsDeviceManager(this);
graphics.GraphicsDevice.DisplayMode.Width
graphics.GraphicsDevice.DisplayMode.Height
//3.
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height
//4.
foreach (DisplayMode dm in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
{
Console.WriteLine(dm.Width);
Console.WriteLine(dm.Height);
}
答案 0 :(得分:9)
_ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
_ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
额外引用:System.Drawing,System.Windows.Forms
答案 1 :(得分:0)
如果应用程序以全屏模式启动,则可能有效:
Vector2 resolution = new Vector2(GraphicsDevice.Viewport.Width,GraphicsDevice.Viewport.Height);