Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XNA - Get Current Screen Resolution

Is it possible to get the current desktop screen resolution?

I have a few minor settings in my XNA game one of which is screen resolution. What I want to do is blank out a screen resolution option if it is larger than the current desktop resolution supports.

like image 597
Jpin Avatar asked Jan 21 '12 17:01

Jpin


2 Answers

GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width and .Height will give you the device's current resolution.

Game.GraphicsDevice.Viewport has height and width variables you can query, that will give you the resolution of your viewport. The viewport is usually the size of the window, but that's not guaranteed.

Window.ClientBounds.Width and .Height will give you the resolution of your game window.

like image 59
Nic Foster Avatar answered Sep 19 '22 15:09

Nic Foster


GraphicsAdapter.SupportedDisplayModes will return a collection of all of the supported aspect ratios. You can then show all of the ratios that are in this collection.

like image 30
Justin Self Avatar answered Sep 19 '22 15:09

Justin Self