private static MyDisplayMode[] GetSupportedDisplayModes(Direct3D d3d, int adapterOrdinal) { var modeAvailable = new List <MyDisplayMode>(); var modeMap = new Dictionary <string, MyDisplayMode>(); SharpDX.Direct3D9.Format format = m_backbufferFormat; int modeCount = format == Format.Unknown ? 0 : d3d.GetAdapterModeCount(adapterOrdinal, format); for (int modeIndex = 0; modeIndex < modeCount; modeIndex++) { var mode = d3d.EnumAdapterModes(adapterOrdinal, (SharpDX.Direct3D9.Format)format, modeIndex); string key = format + ";" + mode.Width + ";" + mode.Height + ";" + mode.RefreshRate; MyDisplayMode oldMode; if (!modeMap.TryGetValue(key, out oldMode)) { var displayMode = new MyDisplayMode() { Width = mode.Width, Height = mode.Height, RefreshRate = mode.RefreshRate, AspectRatio = mode.AspectRatio }; modeMap.Add(key, displayMode); modeAvailable.Add(displayMode); } } modeAvailable.Sort(m_refreshRatePriorityComparer); return(modeAvailable.ToArray()); }
public DeviceEnumeration(Direct3D d3d) { InitializeComponent(); _displayModes = new List<DisplayMode>(); _settingsScript = new Script("DisplaySettings.txt"); _adapter = d3d.GetAdapterIdentifier(0); var allowedFormats = new[] { Format.X1R5G5B5, Format.A1R5G5B5, Format.R5G6B5, Format.X8R8G8B8, Format.A8R8G8B8, Format.A2R10G10B10, }; for (var af = 0; af < allowedFormats.Length; af++) { var format = allowedFormats[af]; var modes = d3d.GetAdapterModeCount(0, format); for (var m = 0; m < modes; m++) { var mode = d3d.EnumerateAdapterModes(0, format, m); if (mode.Height < 600) continue; var displayMode = new DisplayMode { Mode = mode, Bpp = af < 3 ? "16 bpp" : "32 bpp" }; _displayModes.Add(displayMode); } } txtAdapterName.Text = _adapter.Description; txtDriverVersion.Text = _adapter.DriverVersion.ToString(); if (_settingsScript.VariableCount == 0) { _windowed = true; rbWindowed.Checked = true; } else { if (_settingsScript.GetBool("windowed")) { _windowed = true; rbWindowed.Checked = true; } else { rbFullscreen.Checked = true; _windowed = false; } } if (!_windowed) { // enable fullscreen options chkVSync.Enabled = true; cbColorFormat.Enabled = true; cbResolution.Enabled = true; cbRefresh.Enabled = true; chkVSync.Checked = _settingsScript.GetBool("vsync"); ResetColorFormats(); long selectedRes = _settingsScript.GetNumber("resolution"); ResetResolution(selectedRes); long refresh = _settingsScript.GetNumber("refresh"); ResetRefresh(refresh); } }
public DeviceEnumeration(Direct3D d3d) { InitializeComponent(); _displayModes = new List <DisplayMode>(); _settingsScript = new Script("DisplaySettings.txt"); _adapter = d3d.GetAdapterIdentifier(0); var allowedFormats = new[] { Format.X1R5G5B5, Format.A1R5G5B5, Format.R5G6B5, Format.X8R8G8B8, Format.A8R8G8B8, Format.A2R10G10B10, }; for (var af = 0; af < allowedFormats.Length; af++) { var format = allowedFormats[af]; var modes = d3d.GetAdapterModeCount(0, format); for (var m = 0; m < modes; m++) { var mode = d3d.EnumerateAdapterModes(0, format, m); if (mode.Height < 600) { continue; } var displayMode = new DisplayMode { Mode = mode, Bpp = af < 3 ? "16 bpp" : "32 bpp" }; _displayModes.Add(displayMode); } } txtAdapterName.Text = _adapter.Description; txtDriverVersion.Text = _adapter.DriverVersion.ToString(); if (_settingsScript.VariableCount == 0) { _windowed = true; rbWindowed.Checked = true; } else { if (_settingsScript.GetBool("windowed")) { _windowed = true; rbWindowed.Checked = true; } else { rbFullscreen.Checked = true; _windowed = false; } } if (!_windowed) { // enable fullscreen options chkVSync.Enabled = true; cbColorFormat.Enabled = true; cbResolution.Enabled = true; cbRefresh.Enabled = true; chkVSync.Checked = _settingsScript.GetBool("vsync"); ResetColorFormats(); long selectedRes = _settingsScript.GetNumber("resolution"); ResetResolution(selectedRes); long refresh = _settingsScript.GetNumber("refresh"); ResetRefresh(refresh); } }