C# / XNA - Device Enumeration
Graphics cards support a variety of resolutions, refresh rates, and aspect ratios. In order to determine which display modes are available. The following function generates these display modes, and enters them into a List of type DisplayMode.
Once the List of DisplayModes is obtained, simply iterate through the available display modes, and populate some sort of user interface control, such as a listbox, combobox, etc, allowing users to select which resolution they want to use. The following options can be accessed through the DisplayMode: Width, Height, AspectRatio, and Format.
Width: Available Screen Width.
Height: Available Screen Height.
Format: Available Surface Format. (Commonly used: COLOR, and BRG565.)
Aspect Ratio: Common Aspect Ratios below, Regular and Widescreen.
1 2 3 4 5 6 7 8 | List<displaymode> dmList = new List<displaymode>(); public void GetDeviceEnumeration() { foreach (DisplayMode dm in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) dmList.Add(dm); } </displaymode></displaymode> |
Width: Available Screen Width.
Height: Available Screen Height.
Format: Available Surface Format. (Commonly used: COLOR, and BRG565.)
Aspect Ratio: Common Aspect Ratios below, Regular and Widescreen.
1 2 | Widescreen = 1.77777779F; // (Aspect Ratio - 16:9) Regular = 1.33333337F; // (Aspect Ratio - 4:3) |
Comments