Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XNA: get screen's width and height

Tags:

fullscreen

xna

how do i get the width and height of the entire screen in XNA?

like image 509
RCIX Avatar asked Sep 04 '09 06:09

RCIX


People also ask

How do I find my screen width and height?

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.

What is width and height of screen?

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".


1 Answers

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.

like image 163
Eddie Parker Avatar answered Sep 28 '22 01:09

Eddie Parker