[英]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.