繁体   English   中英

如何获得显示分辨率(屏幕尺寸)?

[英]How to get display resolution (screen size)?

如何在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);
}
_ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
_ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;

额外的引用:System.Drawing,System.Windows.Forms

如果应用程序以全屏模式启动,则可能有效:

Vector2 resolution = new Vector2(GraphicsDevice.Viewport.Width,GraphicsDevice.Viewport.Height);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM