Example #1
0
        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);
            }
        }