how do i get the width and height of the entire screen in XNA?
The size of a 16:9 screen depends on how long the screen's diagonal is, as 16:9 is merely the ratio of the screen's width to its height. If you have the screens diagonal, you can multiply that measurement by 0.872 to get the screen's width. You can also multiply the diagonal by 0.49 to get the screen's height.
It is usually quoted as width × height, with the units in pixels: for example, 1024 × 768 means the width is 1024 pixels and the height is 768 pixels. This example would normally be spoken as "ten twenty-four by seven sixty-eight" or "ten twenty-four by seven six eight".
Empirically I've found that in XNA 4.0 I need to use
GraphicsDevice.Viewport.Width GraphicsDevice.Viewport.Height
when running windowed mode, as I find
GraphicsDevice.DisplayMode.Width GraphicsDevice.DisplayMode.Height
gives me the resolution of the entire screen.
Hopefully this helps someone else out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With