Пример #1
0
 /// <summary>	
 /// <p>[This documentation is preliminary and is subject to change.]</p><p><strong>Applies to: </strong>desktop apps | Metro style apps</p><p>Gets the display modes that match the requested format and other input options.</p>	
 /// </summary>	
 /// <param name="enumFormat"><dd> <p>A <strong><see cref="SharpDX.DXGI.Format"/></strong>-typed value for the color format.</p> </dd></param>	
 /// <param name="flags"><dd> <p>A combination of DXGI_ENUM_MODES-typed values that are combined by using a bitwise OR operation. The resulting value specifies options for display modes to include. You must specify <see cref="SharpDX.DXGI.DisplayModeEnumerationFlags.Scaling"/> to expose the display modes that require scaling.  Centered modes that require no  scaling and correspond directly to the display output are enumerated by default.</p> </dd></param>	
 /// <returns>A list of display modes</returns>	
 /// <remarks>	
 /// <p><strong>GetDisplayModeList1</strong> is updated from  <strong>GetDisplayModeList</strong> to return a list of <strong><see cref="SharpDX.DXGI.ModeDescription1"/></strong> structures, which are updated mode descriptions.  <strong>GetDisplayModeList</strong> behaves as though it calls <strong>GetDisplayModeList1</strong> because  <strong>GetDisplayModeList</strong> can return all of the modes that are specified by DXGI_ENUM_MODES, including stereo mode.  However, <strong>GetDisplayModeList</strong> returns a list of <strong><see cref="SharpDX.DXGI.ModeDescription"/></strong> structures, which are the former mode descriptions and do not indicate stereo mode.</p><p>The <strong>GetDisplayModeList1</strong> method does not enumerate stereo modes unless you specify the <see cref="SharpDX.DXGI.DisplayModeEnumerationFlags.Stereo"/> flag in the <em>Flags</em> parameter.  If you specify <see cref="SharpDX.DXGI.DisplayModeEnumerationFlags.Stereo"/>, stereo modes are included in the list of returned modes that the <em>pDesc</em> parameter points to.  In other words, the method returns both stereo and mono modes.</p><p>In general, when you switch from windowed to full-screen mode, a swap chain automatically chooses a display mode that meets (or exceeds) the resolution, color  depth, and refresh rate of the swap chain. To exercise more control over the display mode, use <strong>GetDisplayModeList1</strong> to poll the set of display modes that are validated  against monitor capabilities, or all modes that match the desktop (if the desktop settings are not validated against the monitor).</p><p>The following example code shows that you need to call <strong>GetDisplayModeList1</strong> twice. First call <strong>GetDisplayModeList1</strong> to get the number of modes available, and second call <strong>GetDisplayModeList1</strong> to return a description of the modes.</p><pre><code> UINT num = 0;	
 /// <see cref="SharpDX.DXGI.Format"/> format = <see cref="SharpDX.DXGI.Format.R32G32B32A32_Float"/>;	
 /// UINT flags         = <see cref="SharpDX.DXGI.DisplayModeEnumerationFlags.Interlaced"/>; pOutput-&gt;GetDisplayModeList1( format, flags, &amp;num, 0); ... <see cref="SharpDX.DXGI.ModeDescription1"/> * pDescs = new <see cref="SharpDX.DXGI.ModeDescription1"/>[num];	
 /// pOutput-&gt;GetDisplayModeList1( format, flags, &amp;num, pDescs); </code></pre>	
 /// </remarks>	
 /// <msdn-id>hh404606</msdn-id>	
 /// <unmanaged>HRESULT IDXGIOutput1::GetDisplayModeList1([In] DXGI_FORMAT EnumFormat,[In] unsigned int Flags,[InOut] unsigned int* pNumModes,[Out, Buffer, Optional] DXGI_MODE_DESC1* pDesc)</unmanaged>	
 /// <unmanaged-short>IDXGIOutput1::GetDisplayModeList1</unmanaged-short>	
 public ModeDescription1[] GetDisplayModeList1(Format enumFormat, DisplayModeEnumerationFlags flags)
 {
     int numberOfDisplayModes = 0;
     GetDisplayModeList1(enumFormat, (int)flags, ref numberOfDisplayModes, null);
     var list = new ModeDescription1[numberOfDisplayModes];
     if (numberOfDisplayModes > 0)
         GetDisplayModeList1(enumFormat, (int)flags, ref numberOfDisplayModes, list);
     return list;
 }
Пример #2
0
        /// <summary>
        /// Enumerates all available display modes for this output and stores them in <see cref="SupportedDisplayModes"/>.
        /// </summary>
        private void InitializeSupportedDisplayModes()
        {
            var modesAvailable = new List <DisplayMode>();
            var modesMap       = new Dictionary <string, DisplayMode>();

#if DIRECTX11_1
            var output1 = output.QueryInterface <Output1>();
#endif

            try
            {
                const DisplayModeEnumerationFlags displayModeEnumerationFlags = DisplayModeEnumerationFlags.Interlaced | DisplayModeEnumerationFlags.Scaling;

                foreach (var format in Enum.GetValues(typeof(DXGI.Format)))
                {
                    var dxgiFormat = (Format)format;
#if DIRECTX11_1
                    var modes = output1.GetDisplayModeList1(dxgiFormat, displayModeEnumerationFlags);
#else
                    var modes = output.GetDisplayModeList(dxgiFormat, displayModeEnumerationFlags);
#endif

                    foreach (var mode in modes)
                    {
                        if (mode.Scaling == DisplayModeScaling.Unspecified)
                        {
                            var key = format + ";" + mode.Width + ";" + mode.Height + ";" + mode.RefreshRate.Numerator + ";" + mode.RefreshRate.Denominator;

                            DisplayMode oldMode;
                            if (!modesMap.TryGetValue(key, out oldMode))
                            {
                                var displayMode = DisplayMode.FromDescription(mode);

                                modesMap.Add(key, displayMode);
                                modesAvailable.Add(displayMode);
                            }
                        }
                    }
                }
            }
            catch (SharpDXException dxgiException)
            {
                if (dxgiException.ResultCode != ResultCode.NotCurrentlyAvailable)
                {
                    throw;
                }
            }

#if DIRECTX11_1
            output1.Dispose();
#endif
            supportedDisplayModes = modesAvailable.ToArray();
        }
Пример #3
0
        /// <summary>
        /// <p>[This documentation is preliminary and is subject to change.]</p><p><strong>Applies to: </strong>desktop apps | Metro style apps</p><p>Gets the display modes that match the requested format and other input options.</p>
        /// </summary>
        /// <param name="enumFormat"><dd> <p>A <strong><see cref="SharpDX.DXGI.Format"/></strong>-typed value for the color format.</p> </dd></param>
        /// <param name="flags"><dd> <p>A combination of DXGI_ENUM_MODES-typed values that are combined by using a bitwise OR operation. The resulting value specifies options for display modes to include. You must specify <see cref="SharpDX.DXGI.DisplayModeEnumerationFlags.Scaling"/> to expose the display modes that require scaling.  Centered modes that require no  scaling and correspond directly to the display output are enumerated by default.</p> </dd></param>
        /// <returns>A list of display modes</returns>
        /// <remarks>
        /// <p><strong>GetDisplayModeList1</strong> is updated from  <strong>GetDisplayModeList</strong> to return a list of <strong><see cref="SharpDX.DXGI.ModeDescription1"/></strong> structures, which are updated mode descriptions.  <strong>GetDisplayModeList</strong> behaves as though it calls <strong>GetDisplayModeList1</strong> because  <strong>GetDisplayModeList</strong> can return all of the modes that are specified by DXGI_ENUM_MODES, including stereo mode.  However, <strong>GetDisplayModeList</strong> returns a list of <strong><see cref="SharpDX.DXGI.ModeDescription"/></strong> structures, which are the former mode descriptions and do not indicate stereo mode.</p><p>The <strong>GetDisplayModeList1</strong> method does not enumerate stereo modes unless you specify the <see cref="SharpDX.DXGI.DisplayModeEnumerationFlags.Stereo"/> flag in the <em>Flags</em> parameter.  If you specify <see cref="SharpDX.DXGI.DisplayModeEnumerationFlags.Stereo"/>, stereo modes are included in the list of returned modes that the <em>pDesc</em> parameter points to.  In other words, the method returns both stereo and mono modes.</p><p>In general, when you switch from windowed to full-screen mode, a swap chain automatically chooses a display mode that meets (or exceeds) the resolution, color  depth, and refresh rate of the swap chain. To exercise more control over the display mode, use <strong>GetDisplayModeList1</strong> to poll the set of display modes that are validated  against monitor capabilities, or all modes that match the desktop (if the desktop settings are not validated against the monitor).</p><p>The following example code shows that you need to call <strong>GetDisplayModeList1</strong> twice. First call <strong>GetDisplayModeList1</strong> to get the number of modes available, and second call <strong>GetDisplayModeList1</strong> to return a description of the modes.</p><pre><code> UINT num = 0;
        /// <see cref="SharpDX.DXGI.Format"/> format = <see cref="SharpDX.DXGI.Format.R32G32B32A32_Float"/>;
        /// UINT flags         = <see cref="SharpDX.DXGI.DisplayModeEnumerationFlags.Interlaced"/>; pOutput-&gt;GetDisplayModeList1( format, flags, &amp;num, 0); ... <see cref="SharpDX.DXGI.ModeDescription1"/> * pDescs = new <see cref="SharpDX.DXGI.ModeDescription1"/>[num];
        /// pOutput-&gt;GetDisplayModeList1( format, flags, &amp;num, pDescs); </code></pre>
        /// </remarks>
        /// <msdn-id>hh404606</msdn-id>
        /// <unmanaged>HRESULT IDXGIOutput1::GetDisplayModeList1([In] DXGI_FORMAT EnumFormat,[In] unsigned int Flags,[InOut] unsigned int* pNumModes,[Out, Buffer, Optional] DXGI_MODE_DESC1* pDesc)</unmanaged>
        /// <unmanaged-short>IDXGIOutput1::GetDisplayModeList1</unmanaged-short>
        public ModeDescription1[] GetDisplayModeList1(Format enumFormat, DisplayModeEnumerationFlags flags)
        {
            int numberOfDisplayModes = 0;

            GetDisplayModeList1(enumFormat, (int)flags, ref numberOfDisplayModes, null);
            var list = new ModeDescription1[numberOfDisplayModes];

            if (numberOfDisplayModes > 0)
            {
                GetDisplayModeList1(enumFormat, (int)flags, ref numberOfDisplayModes, list);
            }
            return(list);
        }
Пример #4
0
        public ModeDescription[] GetDisplayModeList(Format format, DisplayModeEnumerationFlags flags)
        {
            int count = 0;

            GetDisplayModeList(format, (int)flags, ref count, null);
            var result = new ModeDescription[count];

            if (count > 0)
            {
                GetDisplayModeList(format, (int)flags, ref count, result);
            }
            return(result);
        }