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.
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.
ListOnce 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.dmList = new List (); public void GetDeviceEnumeration() { foreach (DisplayMode dm in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) dmList.Add(dm); }
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.
Widescreen = 1.77777779F; // (Aspect Ratio - 16:9) Regular = 1.33333337F; // (Aspect Ratio - 4:3)
Comments