/// <summary> /// Adds all present intervals that are compatible with the device and app to /// the given deviceCombo /// </summary> public void BuildPresentIntervalList(GraphicsDeviceInfo deviceInfo, DeviceCombo deviceCombo) { PresentInterval[] piArray = { PresentInterval.Immediate, PresentInterval.Default, PresentInterval.One, PresentInterval.Two, PresentInterval.Three, PresentInterval.Four, }; foreach (PresentInterval pi in piArray) { if (deviceCombo.IsWindowed) { if (pi == PresentInterval.Two || pi == PresentInterval.Three || pi == PresentInterval.Four) { // These intervals are not supported in windowed mode. continue; } } // Note that PresentInterval.Default is zero, so you // can't do a caps check for it -- it is always available. if (pi == PresentInterval.Default || (deviceInfo.Caps.PresentationIntervals & pi) != (PresentInterval)0) { deviceCombo.PresentIntervalList.Add(pi); } } }
/// <summary> /// Adds all multisample types that are compatible with the device and app to /// the given deviceCombo /// </summary> public void BuildMultiSampleTypeList(DeviceCombo deviceCombo) { MultiSampleType[] msTypeArray = { MultiSampleType.None, MultiSampleType.NonMaskable, MultiSampleType.TwoSamples, MultiSampleType.ThreeSamples, MultiSampleType.FourSamples, MultiSampleType.FiveSamples, MultiSampleType.SixSamples, MultiSampleType.SevenSamples, MultiSampleType.EightSamples, MultiSampleType.NineSamples, MultiSampleType.TenSamples, MultiSampleType.ElevenSamples, MultiSampleType.TwelveSamples, MultiSampleType.ThirteenSamples, MultiSampleType.FourteenSamples, MultiSampleType.FifteenSamples, MultiSampleType.SixteenSamples, }; foreach (MultiSampleType msType in msTypeArray) { int result; int qualityLevels = 0; if (Manager.CheckDeviceMultiSampleType(deviceCombo.AdapterOrdinal, deviceCombo.DevType, deviceCombo.BackBufferFormat, deviceCombo.IsWindowed, msType, out result, out qualityLevels)) { deviceCombo.MultiSampleTypeList.Add(msType); deviceCombo.MultiSampleQualityList.Add(qualityLevels); } } }
/// <summary> /// Adds all vertex processing types that are compatible with the device and app to /// the given deviceCombo /// </summary> public void BuildVertexProcessingTypeList(GraphicsDeviceInfo deviceInfo, DeviceCombo deviceCombo) { if (deviceInfo.Caps.DeviceCaps.SupportsHardwareTransformAndLight) { if (deviceInfo.Caps.DeviceCaps.SupportsPureDevice) { if (ConfirmDeviceCallback == null || ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.PureHardware, deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat)) { deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.PureHardware); } } if (ConfirmDeviceCallback == null || ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Hardware, deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat)) { deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Hardware); } if (AppUsesMixedVP && (ConfirmDeviceCallback == null || ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Mixed, deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat))) { deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Mixed); } } if (ConfirmDeviceCallback == null || ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Software, deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat)) { deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Software); } }
/// <summary> /// Adds all depth/stencil formats that are compatible with the device and app to /// the given deviceCombo /// </summary> public void BuildDepthStencilFormatList(DeviceCombo deviceCombo) { DepthFormat[] depthStencilFormatArray = { DepthFormat.D16, DepthFormat.D15S1, DepthFormat.D24X8, DepthFormat.D24S8, DepthFormat.D24X4S4, DepthFormat.D32, }; foreach (DepthFormat depthStencilFmt in depthStencilFormatArray) { if (GraphicsUtility.GetDepthBits(depthStencilFmt) < AppMinDepthBits) continue; if (GraphicsUtility.GetStencilBits(depthStencilFmt) < AppMinStencilBits) continue; if (Manager.CheckDeviceFormat(deviceCombo.AdapterOrdinal, deviceCombo.DevType, deviceCombo.AdapterFormat, Usage.DepthStencil, ResourceType.Surface, depthStencilFmt)) { if (Manager.CheckDepthStencilMatch(deviceCombo.AdapterOrdinal, deviceCombo.DevType, deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat, depthStencilFmt)) { deviceCombo.DepthStencilFormatList.Add(depthStencilFmt); } } } }
/// <summary> /// Adds all depth/stencil formats that are compatible with the device and app to /// the given deviceCombo /// </summary> public void BuildDepthStencilFormatList(DeviceCombo deviceCombo) { DepthFormat[] depthStencilFormatArray = { DepthFormat.D16, DepthFormat.D15S1, DepthFormat.D24X8, DepthFormat.D24S8, DepthFormat.D24X4S4, DepthFormat.D32, }; foreach (DepthFormat depthStencilFmt in depthStencilFormatArray) { if (GraphicsUtility.GetDepthBits(depthStencilFmt) < AppMinDepthBits) { continue; } if (GraphicsUtility.GetStencilBits(depthStencilFmt) < AppMinStencilBits) { continue; } if (Manager.CheckDeviceFormat(deviceCombo.AdapterOrdinal, deviceCombo.DevType, deviceCombo.AdapterFormat, Usage.DepthStencil, ResourceType.Surface, depthStencilFmt)) { if (Manager.CheckDepthStencilMatch(deviceCombo.AdapterOrdinal, deviceCombo.DevType, deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat, depthStencilFmt)) { deviceCombo.DepthStencilFormatList.Add(depthStencilFmt); } } } }
/// <summary> /// Respond to a change of selected multisample type. /// </summary> private void MultisampleTypeChanged(object sender, System.EventArgs e) { settings.MultisampleType = (MultiSampleType)multisampleComboBox.SelectedItem; // Find current max multisample quality int maxQuality = 0; DeviceCombo deviceCombo = settings.DeviceCombo; for (int i = 0; i < deviceCombo.MultiSampleQualityList.Count; i++) { if ((MultiSampleType)deviceCombo.MultiSampleTypeList[i] == settings.MultisampleType) { maxQuality = (int)deviceCombo.MultiSampleQualityList[i]; break; } } // Update multisample quality list based on new type multisampleQualityComboBox.Items.Clear(); for (int iLevel = 0; iLevel < maxQuality; iLevel++) { multisampleQualityComboBox.Items.Add(iLevel); if (settings.MultisampleQuality == iLevel) { multisampleQualityComboBox.SelectedItem = iLevel; } } if (multisampleQualityComboBox.SelectedItem == null && multisampleQualityComboBox.Items.Count > 0) { multisampleQualityComboBox.SelectedIndex = 0; } }
/// <summary> /// Finds any depthstencil formats that are incompatible with multisample types and /// builds a list of them. /// </summary> public void BuildDepthStencilMultiSampleConflictList(DeviceCombo deviceCombo) { DepthStencilMultiSampleConflict DSMSConflict; foreach (DepthFormat dsFmt in deviceCombo.DepthStencilFormatList) { foreach (MultiSampleType msType in deviceCombo.MultiSampleTypeList) { if (!Manager.CheckDeviceMultiSampleType(deviceCombo.AdapterOrdinal, deviceCombo.DevType, (Format)dsFmt, deviceCombo.IsWindowed, msType)) { DSMSConflict = new DepthStencilMultiSampleConflict(); DSMSConflict.DepthStencilFormat = dsFmt; DSMSConflict.MultiSampleType = msType; deviceCombo.DepthStencilMultiSampleConflictList.Add(DSMSConflict); } } } }
public IPodChooseWindow(Store s) : base(IntPtr.Zero) { store = s; Glade.XML gxml = new Glade.XML (null, "IPodWindow.glade", "window", null); gxml.Autoconnect (this); Raw = window.Handle; combo = new DeviceCombo (); combo.Changed += OnDeviceChanged; combo_container.PackStart (combo, true, true, 0); update_button.Clicked += OnUpdateClicked; window.Icon = MainClass.program_pixbuf48; notify = new ThreadNotify (new ReadyEvent (OnNotify)); progress = new ProgressDialog (this); SetDevice (); window.Response += OnWindowResponse; window.DeleteEvent += OnWindowDeleteEvent; combo.ShowAll (); }
/// <summary> /// Enumerates DeviceCombos for a particular device /// </summary> protected void EnumerateDeviceCombos(GraphicsDeviceInfo deviceInfo, ArrayList adapterFormatList) { Format[] backBufferFormatArray = new Format[] { Format.A8R8G8B8, Format.X8R8G8B8, Format.A2R10G10B10, Format.R5G6B5, Format.A1R5G5B5, Format.X1R5G5B5, }; bool[] isWindowedArray = new bool[] { false, true }; // See which adapter formats are supported by this device foreach (Format adapterFormat in adapterFormatList) { foreach (Format backBufferFormat in backBufferFormatArray) { if (GraphicsUtility.GetAlphaChannelBits(backBufferFormat) < AppMinAlphaChannelBits) { continue; } foreach (bool isWindowed in isWindowedArray) { if (!isWindowed && AppRequiresWindowed) { continue; } if (isWindowed && AppRequiresFullscreen) { continue; } if (!Manager.CheckDeviceType(deviceInfo.AdapterOrdinal, deviceInfo.DevType, adapterFormat, backBufferFormat, isWindowed)) { continue; } // At this point, we have an adapter/device/adapterformat/backbufferformat/iswindowed // DeviceCombo that is supported by the system. We still need to confirm that it's // compatible with the app, and find one or more suitable depth/stencil buffer format, // multisample type, vertex processing type, and present interval. DeviceCombo deviceCombo = new DeviceCombo(); deviceCombo.AdapterOrdinal = deviceInfo.AdapterOrdinal; deviceCombo.DevType = deviceInfo.DevType; deviceCombo.AdapterFormat = adapterFormat; deviceCombo.BackBufferFormat = backBufferFormat; deviceCombo.IsWindowed = isWindowed; if (AppUsesDepthBuffer) { BuildDepthStencilFormatList(deviceCombo); if (deviceCombo.DepthStencilFormatList.Count == 0) { continue; } } BuildMultiSampleTypeList(deviceCombo); if (deviceCombo.MultiSampleTypeList.Count == 0) { continue; } BuildDepthStencilMultiSampleConflictList(deviceCombo); BuildVertexProcessingTypeList(deviceInfo, deviceCombo); if (deviceCombo.VertexProcessingTypeList.Count == 0) { continue; } BuildPresentIntervalList(deviceInfo, deviceCombo); if (deviceCombo.PresentIntervalList.Count == 0) { continue; } deviceInfo.DeviceComboList.Add(deviceCombo); } } } }
/// <summary> /// Adds all vertex processing types that are compatible with the device and app to /// the given deviceCombo /// </summary> public void BuildVertexProcessingTypeList(GraphicsDeviceInfo deviceInfo, DeviceCombo deviceCombo) { if (deviceInfo.Caps.DeviceCaps.SupportsHardwareTransformAndLight) { if (deviceInfo.Caps.DeviceCaps.SupportsPureDevice) { if (ConfirmDeviceCallback == null || ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.PureHardware, deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat)) { deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.PureHardware); } } if (ConfirmDeviceCallback == null || ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Hardware, deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat)) { deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Hardware); } if (AppUsesMixedVP && (ConfirmDeviceCallback == null || ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Mixed, deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat))) { deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Mixed); } } if (ConfirmDeviceCallback == null || ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Software, deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat)) { deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Software); } }
/// <summary> /// Enumerates DeviceCombos for a particular device /// </summary> protected void EnumerateDeviceCombos(GraphicsDeviceInfo deviceInfo, ArrayList adapterFormatList) { Format[] backBufferFormatArray = new Format[] { Format.A8R8G8B8, Format.X8R8G8B8, Format.A2R10G10B10, Format.R5G6B5, Format.A1R5G5B5, Format.X1R5G5B5, }; bool[] isWindowedArray = new bool[] { false, true }; // See which adapter formats are supported by this device foreach (Format adapterFormat in adapterFormatList) { foreach (Format backBufferFormat in backBufferFormatArray) { if (GraphicsUtility.GetAlphaChannelBits(backBufferFormat) < AppMinAlphaChannelBits) continue; foreach (bool isWindowed in isWindowedArray) { if (!isWindowed && AppRequiresWindowed) continue; if (isWindowed && AppRequiresFullscreen) continue; if (!Manager.CheckDeviceType(deviceInfo.AdapterOrdinal, deviceInfo.DevType, adapterFormat, backBufferFormat, isWindowed)) { continue; } // At this point, we have an adapter/device/adapterformat/backbufferformat/iswindowed // DeviceCombo that is supported by the system. We still need to confirm that it's // compatible with the app, and find one or more suitable depth/stencil buffer format, // multisample type, vertex processing type, and present interval. DeviceCombo deviceCombo = new DeviceCombo(); deviceCombo.AdapterOrdinal = deviceInfo.AdapterOrdinal; deviceCombo.DevType = deviceInfo.DevType; deviceCombo.AdapterFormat = adapterFormat; deviceCombo.BackBufferFormat = backBufferFormat; deviceCombo.IsWindowed = isWindowed; if (AppUsesDepthBuffer) { BuildDepthStencilFormatList(deviceCombo); if (deviceCombo.DepthStencilFormatList.Count == 0) continue; } BuildMultiSampleTypeList(deviceCombo); if (deviceCombo.MultiSampleTypeList.Count == 0) continue; BuildDepthStencilMultiSampleConflictList(deviceCombo); BuildVertexProcessingTypeList(deviceInfo, deviceCombo); if (deviceCombo.VertexProcessingTypeList.Count == 0) continue; BuildPresentIntervalList(deviceInfo, deviceCombo); if (deviceCombo.PresentIntervalList.Count == 0) continue; deviceInfo.DeviceComboList.Add(deviceCombo); } } } }
/// <summary> /// Adds all present intervals that are compatible with the device and app to /// the given deviceCombo /// </summary> public void BuildPresentIntervalList(GraphicsDeviceInfo deviceInfo, DeviceCombo deviceCombo) { PresentInterval[] piArray = { PresentInterval.Immediate, PresentInterval.Default, PresentInterval.One, PresentInterval.Two, PresentInterval.Three, PresentInterval.Four, }; foreach (PresentInterval pi in piArray) { if (deviceCombo.IsWindowed) { if (pi == PresentInterval.Two || pi == PresentInterval.Three || pi == PresentInterval.Four) { // These intervals are not supported in windowed mode. continue; } } // Note that PresentInterval.Default is zero, so you // can't do a caps check for it -- it is always available. if (pi == PresentInterval.Default || (deviceInfo.Caps.PresentationIntervals & pi) != (PresentInterval)0) { deviceCombo.PresentIntervalList.Add(pi); } } }
/// <summary> /// Adds all multisample types that are compatible with the device and app to /// the given deviceCombo /// </summary> public void BuildMultiSampleTypeList(DeviceCombo deviceCombo) { MultiSampleType[] msTypeArray = { MultiSampleType.None, MultiSampleType.NonMaskable, MultiSampleType.TwoSamples, MultiSampleType.ThreeSamples, MultiSampleType.FourSamples, MultiSampleType.FiveSamples, MultiSampleType.SixSamples, MultiSampleType.SevenSamples, MultiSampleType.EightSamples, MultiSampleType.NineSamples, MultiSampleType.TenSamples, MultiSampleType.ElevenSamples, MultiSampleType.TwelveSamples, MultiSampleType.ThirteenSamples, MultiSampleType.FourteenSamples, MultiSampleType.FifteenSamples, MultiSampleType.SixteenSamples, }; foreach (MultiSampleType msType in msTypeArray) { int result; int qualityLevels = 0; if (Manager.CheckDeviceMultiSampleType(deviceCombo.AdapterOrdinal, deviceCombo.DevType, deviceCombo.BackBufferFormat, deviceCombo.IsWindowed, msType, out result, out qualityLevels)) { deviceCombo.MultiSampleTypeList.Add(msType); deviceCombo.MultiSampleQualityList.Add(qualityLevels); } } }
/// <summary> /// Finds any depthstencil formats that are incompatible with multisample types and /// builds a list of them. /// </summary> public void BuildDepthStencilMultiSampleConflictList(DeviceCombo deviceCombo) { DepthStencilMultiSampleConflict DSMSConflict; foreach (DepthFormat dsFmt in deviceCombo.DepthStencilFormatList) { foreach (MultiSampleType msType in deviceCombo.MultiSampleTypeList) { if (!Manager.CheckDeviceMultiSampleType(deviceCombo.AdapterOrdinal, deviceCombo.DevType, (Format)dsFmt, deviceCombo.IsWindowed, msType)) { DSMSConflict = new DepthStencilMultiSampleConflict(); DSMSConflict.DepthStencilFormat = dsFmt; DSMSConflict.MultiSampleType = msType; deviceCombo.DepthStencilMultiSampleConflictList.Add(DSMSConflict); } } } }
public bool FindBestWindowedMode(bool doesRequireHardware, bool doesRequireReference) { // Get display mode of primary adapter (which is assumed to be where the window will appear) DisplayMode primaryDesktopDisplayMode = Manager.Adapters[0].CurrentDisplayMode; GraphicsAdapterInfo bestAdapterInfo = null; GraphicsDeviceInfo bestDeviceInfo = null; DeviceCombo bestDeviceCombo = null; foreach (GraphicsAdapterInfo adapterInfo in enumerationSettings.AdapterInfoList) { foreach (GraphicsDeviceInfo deviceInfo in adapterInfo.DeviceInfoList) { if (doesRequireHardware && deviceInfo.DevType != DeviceType.Hardware) { continue; } if (doesRequireReference && deviceInfo.DevType != DeviceType.Reference) { continue; } foreach (DeviceCombo deviceCombo in deviceInfo.DeviceComboList) { bool adapterMatchesBackBuffer = (deviceCombo.BackBufferFormat == deviceCombo.AdapterFormat); if (!deviceCombo.IsWindowed) { continue; } if (deviceCombo.AdapterFormat != primaryDesktopDisplayMode.Format) { continue; } // If we haven't found a compatible DeviceCombo yet, or if this set // is better (because it's a HAL, and/or because formats match better), // save it if (bestDeviceCombo == null || bestDeviceCombo.DevType != DeviceType.Hardware && deviceInfo.DevType == DeviceType.Hardware || deviceCombo.DevType == DeviceType.Hardware && adapterMatchesBackBuffer) { bestAdapterInfo = adapterInfo; bestDeviceInfo = deviceInfo; bestDeviceCombo = deviceCombo; if (deviceInfo.DevType == DeviceType.Hardware && adapterMatchesBackBuffer) { // This windowed device combo looks great -- take it goto EndWindowedDeviceComboSearch; } // Otherwise keep looking for a better windowed device combo } } } } EndWindowedDeviceComboSearch: if (bestDeviceCombo == null) { return(false); } graphicsSettings.WindowedAdapterInfo = bestAdapterInfo; graphicsSettings.WindowedDeviceInfo = bestDeviceInfo; graphicsSettings.WindowedDeviceCombo = bestDeviceCombo; graphicsSettings.IsWindowed = true; graphicsSettings.WindowedDisplayMode = primaryDesktopDisplayMode; graphicsSettings.WindowedWidth = ourRenderTarget.ClientRectangle.Right - ourRenderTarget.ClientRectangle.Left; graphicsSettings.WindowedHeight = ourRenderTarget.ClientRectangle.Bottom - ourRenderTarget.ClientRectangle.Top; if (enumerationSettings.AppUsesDepthBuffer) { graphicsSettings.WindowedDepthStencilBufferFormat = (DepthFormat)bestDeviceCombo.DepthStencilFormatList[0]; } graphicsSettings.WindowedMultisampleType = (MultiSampleType)bestDeviceCombo.MultiSampleTypeList[0]; graphicsSettings.WindowedMultisampleQuality = 0; graphicsSettings.WindowedVertexProcessingType = (VertexProcessingType)bestDeviceCombo.VertexProcessingTypeList[0]; graphicsSettings.WindowedPresentInterval = (PresentInterval)bestDeviceCombo.PresentIntervalList[0]; return(true); }
public bool FindBestFullscreenMode(bool doesRequireHardware, bool doesRequireReference) { DisplayMode adapterDesktopDisplayMode = new DisplayMode(); DisplayMode bestAdapterDesktopDisplayMode = new DisplayMode(); DisplayMode bestDisplayMode = new DisplayMode(); bestAdapterDesktopDisplayMode.Width = 0; bestAdapterDesktopDisplayMode.Height = 0; bestAdapterDesktopDisplayMode.Format = 0; bestAdapterDesktopDisplayMode.RefreshRate = 0; GraphicsAdapterInfo bestAdapterInfo = null; GraphicsDeviceInfo bestDeviceInfo = null; DeviceCombo bestDeviceCombo = null; foreach (GraphicsAdapterInfo adapterInfo in enumerationSettings.AdapterInfoList) { adapterDesktopDisplayMode = Manager.Adapters[adapterInfo.AdapterOrdinal].CurrentDisplayMode; foreach (GraphicsDeviceInfo deviceInfo in adapterInfo.DeviceInfoList) { if (doesRequireHardware && deviceInfo.DevType != DeviceType.Hardware) { continue; } if (doesRequireReference && deviceInfo.DevType != DeviceType.Reference) { continue; } foreach (DeviceCombo deviceCombo in deviceInfo.DeviceComboList) { bool adapterMatchesBackBuffer = (deviceCombo.BackBufferFormat == deviceCombo.AdapterFormat); bool adapterMatchesDesktop = (deviceCombo.AdapterFormat == adapterDesktopDisplayMode.Format); if (deviceCombo.IsWindowed) { continue; } // If we haven't found a compatible set yet, or if this set // is better (because it's a HAL, and/or because formats match better), // save it if (bestDeviceCombo == null || bestDeviceCombo.DevType != DeviceType.Hardware && deviceInfo.DevType == DeviceType.Hardware || bestDeviceCombo.DevType == DeviceType.Hardware && bestDeviceCombo.AdapterFormat != adapterDesktopDisplayMode.Format && adapterMatchesDesktop || bestDeviceCombo.DevType == DeviceType.Hardware && adapterMatchesDesktop && adapterMatchesBackBuffer) { bestAdapterDesktopDisplayMode = adapterDesktopDisplayMode; bestAdapterInfo = adapterInfo; bestDeviceInfo = deviceInfo; bestDeviceCombo = deviceCombo; if (deviceInfo.DevType == DeviceType.Hardware && adapterMatchesDesktop && adapterMatchesBackBuffer) { // This fullscreen device combo looks great -- take it goto EndFullscreenDeviceComboSearch; } // Otherwise keep looking for a better fullscreen device combo } } } } EndFullscreenDeviceComboSearch: if (bestDeviceCombo == null) { return(false); } // Need to find a display mode on the best adapter that uses pBestDeviceCombo->AdapterFormat // and is as close to bestAdapterDesktopDisplayMode's res as possible bestDisplayMode.Width = 0; bestDisplayMode.Height = 0; bestDisplayMode.Format = 0; bestDisplayMode.RefreshRate = 0; foreach (DisplayMode displayMode in bestAdapterInfo.DisplayModeList) { if (displayMode.Format != bestDeviceCombo.AdapterFormat) { continue; } if (displayMode.Width == bestAdapterDesktopDisplayMode.Width && displayMode.Height == bestAdapterDesktopDisplayMode.Height && displayMode.RefreshRate == bestAdapterDesktopDisplayMode.RefreshRate) { // found a perfect match, so stop bestDisplayMode = displayMode; break; } else if (displayMode.Width == bestAdapterDesktopDisplayMode.Width && displayMode.Height == bestAdapterDesktopDisplayMode.Height && displayMode.RefreshRate > bestDisplayMode.RefreshRate) { // refresh rate doesn't match, but width/height match, so keep this // and keep looking bestDisplayMode = displayMode; } else if (bestDisplayMode.Width == bestAdapterDesktopDisplayMode.Width) { // width matches, so keep this and keep looking bestDisplayMode = displayMode; } else if (bestDisplayMode.Width == 0) { // we don't have anything better yet, so keep this and keep looking bestDisplayMode = displayMode; } } graphicsSettings.FullscreenAdapterInfo = bestAdapterInfo; graphicsSettings.FullscreenDeviceInfo = bestDeviceInfo; graphicsSettings.FullscreenDeviceCombo = bestDeviceCombo; graphicsSettings.IsWindowed = false; graphicsSettings.FullscreenDisplayMode = bestDisplayMode; if (enumerationSettings.AppUsesDepthBuffer) { graphicsSettings.FullscreenDepthStencilBufferFormat = (DepthFormat)bestDeviceCombo.DepthStencilFormatList[0]; } graphicsSettings.FullscreenMultisampleType = (MultiSampleType)bestDeviceCombo.MultiSampleTypeList[0]; graphicsSettings.FullscreenMultisampleQuality = 0; graphicsSettings.FullscreenVertexProcessingType = (VertexProcessingType)bestDeviceCombo.VertexProcessingTypeList[0]; graphicsSettings.FullscreenPresentInterval = (PresentInterval)bestDeviceCombo.PresentIntervalList[0]; return(true); }