48

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

3 Answers 3

81

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.

1
  • 5
    That was actually what i was asking for; window width/height is a different thing.
    – RCIX
    Nov 11, 2010 at 6:13
62

This seems to be it (just googled for "xna screen width height" myself):

GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width
0
3

GraphicsDevice.Viewport.Bounds - this returns Rectangle2D and it has parameters Width and Height.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.