Example #1
0
        private void TryAddDeviceWithDisplayMode(GameGraphicsParameters prefferedParameters,
                                                 GraphicsAdapter graphicsAdapter,
                                                 GraphicsDeviceInformation deviceInfo,
                                                 List<GraphicsDeviceInformation> graphicsDeviceInfos)
        {
            // if we want to switch to fullscreen, try to find only needed output, otherwise check them all
            if (prefferedParameters.IsFullScreen)
            {
                if (prefferedParameters.PreferredFullScreenOutputIndex < graphicsAdapter.OutputsCount)
                {
                    var output = graphicsAdapter.GetOutputAt(prefferedParameters.PreferredFullScreenOutputIndex);
                    TryAddDeviceFromOutput(prefferedParameters, output, deviceInfo, graphicsDeviceInfos);
                }
            }
            else
            {
                for (var i = 0; i < graphicsAdapter.OutputsCount; i++)
                {
                    var output = graphicsAdapter.GetOutputAt(i);
                    TryAddDeviceFromOutput(prefferedParameters, output, deviceInfo, graphicsDeviceInfos);
                }
            }


        }
Example #2
0
        /// <summary>
        /// Appends the information about current graphics adapter and its output and adds it to the list of available graphics modes
        /// </summary>
        /// <param name="sb">Where to write the information</param>
        /// <param name="adapter">The adapter whose information needs to be analyzed</param>
        private void AppendAdapterInfo(StringBuilder sb, GraphicsAdapter adapter)
        {
            var adapterDescription = adapter.Description;

            // general adapter information
            sb.AppendLine(adapterDescription.Description);
            // onboard video RAM
            sb.AppendFormat("VRAM             : {0}MiB{1}", ToMB(adapterDescription.DedicatedVideoMemory), Environment.NewLine);
            // OS RAM dedicated to the adapter (typical for integrated GPUs)
            sb.AppendFormat("Dedicated OS RAM : {0}MiB{1}", ToMB(adapterDescription.DedicatedSystemMemory), Environment.NewLine);
            // OS RAM that can be shared with the adapter (for example, 'Turbo Cache' for NVidia GPUs)
            sb.AppendFormat("Shared OS RAM    : {0}MiB{1}", ToMB(adapterDescription.SharedSystemMemory), Environment.NewLine);

            // iterate trough all outputs attached to this adapter
            for (var i = 0; i < adapter.OutputsCount; i++)
            {
                // write its information
                var output = adapter.GetOutputAt(i);
                sb.AppendFormat("Output {0}; ", i);

                var description = ((Output)output).Description;
                var desktopBounds = description.DesktopBounds;

                sb.AppendFormat("{0}; Attached to desktop: {1}; Desktop bounds: ({2},{3}; {4},{5}); ",
                                description.DeviceName,
                                description.IsAttachedToDesktop,
                                desktopBounds.Left,
                                desktopBounds.Top,
                                desktopBounds.Right,
                                desktopBounds.Bottom);

                sb.AppendLine();
                sb.Append("\tCurrent display mode: ");

                // if there is a display mode - write its information and add it in the list of available modes
                var currentDisplayMode = output.CurrentDisplayMode;
                if (currentDisplayMode != null)
                {
                    if (availableModes.Count < 10)
                    {
                        var modeInfo = new ModeInfo(adapter, i, true, desktopBounds.Width, desktopBounds.Height);
                        availableModes.Add(modeInfo);
                    }

                    sb.AppendFormat("{0}x{1}@{2}, {3}",
                                    currentDisplayMode.Width,
                                    currentDisplayMode.Height,
                                    currentDisplayMode.RefreshRate.Numerator / currentDisplayMode.RefreshRate.Denominator,
                                    currentDisplayMode.Format);
                }
                else
                {
                    sb.Append("null");
                }

                sb.AppendLine();
            }
        }