How to get display resolution (screen size)?
21,114
_ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
_ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
extra references: System.Drawing , System.Windows.Forms
Comments
-
dimitris93 almost 2 years
How to get display resolution in XNA/Monogame ? I tried these on my monitor (1600x900):
The below give me 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); }
-
dimitris93 over 9 yearsyou cant start it in full screen if you cant calculate the screens size in the first place, i answered my own question btw
-
ViNi over 9 yearsNice, you could try this as well: msdn.microsoft.com/en-us/library/bb195024.aspx
-
dimitris93 over 9 years
this.graphics.IsFullScreen = true;
this actually doesn't work, some people say its xbox only -
John Lord over 4 yearsit does work. You have to do this: graphics = new GraphicsDeviceManager(this); graphics.IsFullScreen = true; graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 960; graphics.ApplyChanges();