简体   繁体   中英

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM