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.
List dmList = new List();
  
public void GetDeviceEnumeration()
{          
    foreach (DisplayMode dm in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
        dmList.Add(dm);
}
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.

Widescreen = 1.77777779F;   // (Aspect Ratio - 16:9)
Regular = 1.33333337F;      // (Aspect Ratio - 4:3)
Post a Comment

Popular posts from this blog

C# - ListView Item Spacing (Padding)

IIS / ASP.NET - Run all Managed Modules for All Requests (RAMMFAR)

IIS / ASP.NET - Disabling Compatibility Mode/View (Internet Explorer)