Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        internal DisplayModeCollection(Direct3D direct3D, int adapter, Format format) : base(new List <DisplayMode>())
        {
            int count = direct3D.GetAdapterModeCount(adapter, format);

            for (int i = 0; i < count; i++)
            {
                Items.Add(direct3D.EnumAdapterModes(adapter, format, i));
            }
        }
        /// <summary> Gets the display modes supported by this adapter. </summary>
        public List <DisplayMode> GetDisplayModes(Format format)
        {
            int count = d3d.GetAdapterModeCount(Adapter, format);
            List <DisplayMode> items = new List <DisplayMode>(count);

            for (int i = 0; i < count; i++)
            {
                items.Add(d3d.EnumAdapterModes(Adapter, format, i));
            }
            return(items);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a collection of supported display modes for a particular Format.
        /// </summary>
        /// <returns>a read-only collection of display modes</returns>
        private DisplayMode[] GetSupportedDisplayModes()
        {
            var modeAvailable = new List <DisplayMode>();
            var modeMap       = new Dictionary <string, DisplayMode>();

            try
            {
                Direct3D9.Format format = Format.X8R8G8B8;

                int modeCount = format == Format.Unknown ? 0 : D3D.GetAdapterModeCount(adapterOrdinal, format);
                for (int modeIndex = 0; modeIndex < modeCount; modeIndex++)
                {
                    DisplayMode mode = D3D.EnumAdapterModes(adapterOrdinal, (Direct3D9.Format)format, modeIndex);

                    string key = format + ";" + mode.Width + ";" + mode.Height + ";" + mode.RefreshRate;

                    DisplayMode oldMode;
                    if (!modeMap.TryGetValue(key, out oldMode))
                    {
                        var displayMode = new DisplayMode()
                        {
                            Format      = mode.Format,
                            Width       = mode.Width,
                            Height      = mode.Height,
                            RefreshRate = mode.RefreshRate
                        };

                        modeMap.Add(key, displayMode);
                        modeAvailable.Add(displayMode);
                    }
                }
            }
            catch (SharpDXException dxgiException)
            {
                if (dxgiException.ResultCode != ResultCode.NotAvailable)
                {
                    throw;
                }
            }
            return(modeAvailable.ToArray());
        }