RCIX
RCIX

Reputation: 39427

XNA: get screen's width and height

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

Upvotes: 47

Views: 45576

Answers (3)

ikillapps
ikillapps

Reputation: 96

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

Upvotes: 3

Eddie Parker
Eddie Parker

Reputation: 4888

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.

Upvotes: 79

Adrian Grigore
Adrian Grigore

Reputation: 33318

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

GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width

Upvotes: 62

Related Questions