public static ModeDescription GetAdapterDisplayMode(int adapterOrdinal, int outputOrdinal)
        {
            OutputInfo10 outputInfo = Enumeration10.GetOutputInfo(adapterOrdinal, outputOrdinal);

            ModeDescription mode = new ModeDescription();

            mode.RefreshRate      = new Rational(0, 0);
            mode.Format           = Format.R8G8B8A8_UNorm;
            mode.Scaling          = DisplayModeScaling.Unspecified;
            mode.ScanlineOrdering = DisplayModeScanlineOrdering.Unspecified;
            mode.Width            = 640;
            mode.Height           = 480;

            if (outputInfo != null)
            {
                Rectangle rectangle = outputInfo.OutputDescription.DesktopBounds;
                mode.Width  = rectangle.Width;
                mode.Height = rectangle.Height;
            }

            if (mode.Format == Format.B8G8R8A8_UNorm)
            {
                mode.Format = Format.R8G8B8A8_UNorm;
            }

            return(mode);
        }
예제 #2
0
        static void EnumerateOutputs(AdapterInfo10 adapterInfo)
        {
            for (int i = 0; i < adapterInfo.Adapter.GetOutputCount(); i++)
            {
                Output output = adapterInfo.Adapter.GetOutput(i);

                OutputInfo10 outputInfo = new OutputInfo10();
                outputInfo.OutputDescription = output.Description;
                outputInfo.OutputOrdinal     = i;
                outputInfo.Output            = output;

                EnumerateDisplayModes(outputInfo);
                if (outputInfo.DisplayModes.Count == 0)
                {
                    continue;
                }

                adapterInfo.Outputs.Add(outputInfo);
                output.Dispose();
            }
        }
예제 #3
0
        static void EnumerateDisplayModes(OutputInfo10 outputInfo)
        {
            Format[] allowedFormats = { Format.R8G8B8A8_UNorm,     Format.R8G8B8A8_UNorm_SRGB,
                                        Format.R16G16B16A16_Float, Format.R10G10B10A2_UNorm };

            foreach (Format format in allowedFormats)
            {
                ReadOnlyCollection <ModeDescription> modes = outputInfo.Output.GetDisplayModeList(format, DisplayModeEnumerationFlags.Scaling);
                foreach (ModeDescription mode in modes)
                {
                    if (MinimumSettings != null)
                    {
                        if (mode.Width < MinimumSettings.BackBufferWidth ||
                            mode.Height < MinimumSettings.BackBufferHeight ||
                            (int)ConversionMethods.ToFloat(mode.RefreshRate) < MinimumSettings.RefreshRate)
                        {
                            continue;
                        }
                    }

                    outputInfo.DisplayModes.Add(mode);
                }
            }
        }