Esempio n. 1
0
        private void InitializeDeviceResources()
        {
            ModeDescription backBufferDesc = new ModeDescription(Width, Height, new Rational(60, 1), Format.R8G8B8A8_UNorm);

            // Descriptor for the swap chain
            SwapChainDescription swapChainDesc = new SwapChainDescription()
            {
                ModeDescription = backBufferDesc,
                SampleDescription = new SampleDescription(1, 0),
                Usage = Usage.RenderTargetOutput,
                BufferCount = 1,
                OutputHandle = renderForm.Handle,
                IsWindowed = true
            };

            // Create device and swap chain
            D3D11.Device.CreateWithSwapChain(DriverType.Hardware, D3D11.DeviceCreationFlags.None, swapChainDesc, out d3dDevice, out swapChain);
            d3dDeviceContext = d3dDevice.ImmediateContext;

            // Create render target view for back buffer
            using(D3D11.Texture2D backBuffer = swapChain.GetBackBuffer<D3D11.Texture2D>(0))
            {
                renderTargetView = new D3D11.RenderTargetView(d3dDevice, backBuffer);
            }
        }
Esempio n. 2
0
 internal EngineOutputModeInfo(EngineOutputInfo hostOutput, DXGI.ModeDescription modeDescription)
 {
     m_hostOutput             = hostOutput;
     m_pixelWidth             = modeDescription.Width;
     m_pixelHeight            = modeDescription.Height;
     m_refreshRateNumerator   = modeDescription.RefreshRate.Numerator;
     m_refreshRateDenominator = modeDescription.RefreshRate.Denominator;
 }
Esempio n. 3
0
        /// <summary>
        /// Function to find the nearest video mode to the one specified.
        /// </summary>
        /// <param name="output">Output for the video mode.</param>
        /// <param name="mode">Mode to find.</param>
        /// <returns>The closest matching video mode to the <paramref name="mode"/> parameter.</returns>
        internal GorgonVideoMode FindMode(GI.Output output, GorgonVideoMode mode)
        {
            GI.ModeDescription findMode = GorgonVideoMode.Convert(mode);
            GI.ModeDescription result;

            output.GetClosestMatchingMode(VideoDevice.Graphics.D3DDevice, findMode, out result);

            return(GorgonVideoMode.Convert(result));
        }
Esempio n. 4
0
 /// <summary>	
 /// Gets the display modes that match the requested format and other input options.	
 /// </summary>	
 /// <remarks>	
 /// In general, when switching 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 this API 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). As shown, this API is designed to be called twice. First to get the number of modes available, and second to return a description of the modes. 	
 /// <code> UINT num = 0;	
 /// DXGI_FORMAT format = DXGI_FORMAT_R32G32B32A32_FLOAT;	
 /// UINT flags         = DXGI_ENUM_MODES_INTERLACED; pOutput-&gt;GetDisplayModeList( format, flags, &amp;num, 0); ... DXGI_MODE_DESC * pDescs = new DXGI_MODE_DESC[num];	
 /// pOutput-&gt;GetDisplayModeList( format, flags, &amp;num, pDescs); </code>	
 /// 	
 ///  	
 /// </remarks>	
 /// <param name="format">The color format (see <see cref="SharpDX.DXGI.Format"/>). </param>
 /// <param name="flags">format for modes to include (see {{DXGI_ENUM_MODES}}). DXGI_ENUM_MODES_SCALING needs to be specified to expose the display modes that require scaling.  Centered modes, requiring no  scaling and corresponding directly to the display output, are enumerated by default. </param>
 /// <returns>Returns a list of display modes (see <see cref="SharpDX.DXGI.ModeDescription"/>); </returns>
 /// <unmanaged>HRESULT IDXGIOutput::GetDisplayModeList([None] DXGI_FORMAT EnumFormat,[None] int Flags,[InOut] int* pNumModes,[Out, Buffer, Optional] DXGI_MODE_DESC* pDesc)</unmanaged>
 public ModeDescription[] GetDisplayModeList(Format format, DisplayModeEnumerationFlags flags)
 {
     int numberOfDisplayModes = 0;
     GetDisplayModeList(format, (int) flags, ref numberOfDisplayModes, null);
     var list = new ModeDescription[numberOfDisplayModes];
     if (numberOfDisplayModes > 0)
         GetDisplayModeList(format, (int) flags, ref numberOfDisplayModes, list);
     return list;
 }
Esempio n. 5
0
        /// <summary>
        /// Gets the display modes that match the requested format and other input options.
        /// </summary>
        /// <remarks>
        /// In general, when switching 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 this API 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). As shown, this API is designed to be called twice. First to get the number of modes available, and second to return a description of the modes.
        /// <code> UINT num = 0;
        /// DXGI_FORMAT format = DXGI_FORMAT_R32G32B32A32_FLOAT;
        /// UINT flags         = DXGI_ENUM_MODES_INTERLACED; pOutput-&gt;GetDisplayModeList( format, flags, &amp;num, 0); ... DXGI_MODE_DESC * pDescs = new DXGI_MODE_DESC[num];
        /// pOutput-&gt;GetDisplayModeList( format, flags, &amp;num, pDescs); </code>
        ///
        ///
        /// </remarks>
        /// <param name="format">The color format (see <see cref="SharpDX.DXGI.Format"/>). </param>
        /// <param name="flags">format for modes to include (see {{DXGI_ENUM_MODES}}). DXGI_ENUM_MODES_SCALING needs to be specified to expose the display modes that require scaling.  Centered modes, requiring no  scaling and corresponding directly to the display output, are enumerated by default. </param>
        /// <returns>Returns a list of display modes (see <see cref="SharpDX.DXGI.ModeDescription"/>); </returns>
        /// <unmanaged>HRESULT IDXGIOutput::GetDisplayModeList([None] DXGI_FORMAT EnumFormat,[None] int Flags,[InOut] int* pNumModes,[Out, Buffer, Optional] DXGI_MODE_DESC* pDesc)</unmanaged>
        public ModeDescription[] GetDisplayModeList(Format format, DisplayModeEnumerationFlags flags)
        {
            int numberOfDisplayModes = 0;

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

            if (numberOfDisplayModes > 0)
            {
                GetDisplayModeList(format, (int)flags, ref numberOfDisplayModes, list);
            }
            return(list);
        }
Esempio n. 6
0
    void Start()
    {
        var tex = new Texture2D(640, 480);

        using (var t = new SharpDX.Direct3D11.Texture2D(tex.GetNativeTexturePtr()))
        {
            var desc = t.Description;
            Debug.Log(desc.Width);
            int a = 0;
        }

        var backBufferDesc = new SharpDX.DXGI.ModeDescription(1920, 1080
                                                              , new SharpDX.DXGI.Rational(60, 1), SharpDX.DXGI.Format.R8G8B8A8_UNorm);
    }
Esempio n. 7
0
        public void InitContext()
        {
            var modeDesc = new ModeDescription
            {
                Format = Format.R8G8B8A8_UNorm,
                Height = mWindow.ClientSize.Height,
                Width = mWindow.ClientSize.Width,
                RefreshRate = new Rational(60, 1),
                Scaling = DisplayModeScaling.Unspecified,
                ScanlineOrdering = DisplayModeScanlineOrder.Unspecified
            };

            mSwapChainDesc = new SwapChainDescription()
            {
                BufferCount = 1,
                Flags = SwapChainFlags.None,
                IsWindowed = true,
                OutputHandle = mWindow.Handle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect = SwapEffect.Discard,
                Usage = Usage.RenderTargetOutput
            };

            mOutput.GetClosestMatchingMode(null, modeDesc, out modeDesc);
            modeDesc.Width = mWindow.ClientSize.Width;
            modeDesc.Height = mWindow.ClientSize.Height;
            mSwapChainDesc.ModeDescription = modeDesc;

#if DEBUG
            Device = new Device(Adapter, DeviceCreationFlags.Debug);
#else
            Device = new Device(Adapter);
#endif

            BuildMultisample();

            mSwapChain = new SwapChain(mFactory, Device, mSwapChainDesc);

            Context = Device.ImmediateContext;

            InitRenderTarget();
            InitDepthBuffer();

            Context.OutputMerger.SetRenderTargets(mDepthBuffer, mRenderTarget);
            Context.Rasterizer.SetViewport(new Viewport(0, 0, mWindow.ClientSize.Width, mWindow.ClientSize.Height));

            Texture.InitDefaultTexture(this);

            mWindow.Resize += OnResize;
        }
Esempio n. 8
0
        private void InitializeSwapChain()
        {
            DXGI.ModeDescription backBufferDesc = new DXGI.ModeDescription(Width, Height, new DXGI.Rational(60, 1), DXGI.Format.R8G8B8A8_UNorm);

            DXGI.SwapChainDescription swapChainDesc = new DXGI.SwapChainDescription()
            {
                ModeDescription   = backBufferDesc,
                SampleDescription = new DXGI.SampleDescription(1, 0),
                Usage             = DXGI.Usage.RenderTargetOutput,
                BufferCount       = 1,
                OutputHandle      = renderForm.Handle,
                IsWindowed        = true
            };

            D3D11.Device.CreateWithSwapChain(DriverType.Hardware, D3D11.DeviceCreationFlags.None, swapChainDesc, out device, out swapChain);
        }
Esempio n. 9
0
        private void InitializeDirectXResources()
        {
            var clientSize     = ClientSize;
            var backBufferDesc = new DXGI.ModeDescription(clientSize.Width, clientSize.Height,
                                                          new DXGI.Rational(60, 1), DXGI.Format.R8G8B8A8_UNorm);

            var swapChainDesc = new DXGI.SwapChainDescription()
            {
                ModeDescription   = backBufferDesc,
                SampleDescription = new DXGI.SampleDescription(1, 0),
                Usage             = DXGI.Usage.RenderTargetOutput,
                BufferCount       = 1,
                OutputHandle      = Handle,
                SwapEffect        = DXGI.SwapEffect.Discard,
                IsWindowed        = false
            };

            D3D11.Device.CreateWithSwapChain(D3D.DriverType.Hardware, D3D11.DeviceCreationFlags.BgraSupport,
                                             new[] { D3D.FeatureLevel.Level_10_0 }, swapChainDesc, out _d3DDevice, out var swapChain);
            _d3DDeviceContext = _d3DDevice.ImmediateContext;

            _swapChain = new DXGI.SwapChain1(swapChain.NativePointer);

            _d2DFactory = new D2D1.Factory();

            using (var backBuffer = _swapChain.GetBackBuffer <D3D11.Texture2D>(0))
            {
                _renderTargetView = new D3D11.RenderTargetView(_d3DDevice, backBuffer);
                _renderTarget     = new D2D1.RenderTarget(_d2DFactory, backBuffer.QueryInterface <DXGI.Surface>(),
                                                          new D2D1.RenderTargetProperties(new D2D1.PixelFormat(DXGI.Format.Unknown, D2D1.AlphaMode.Premultiplied)))
                {
                    TextAntialiasMode = D2D1.TextAntialiasMode.Cleartype
                };
            }

            _solidColorBrush = new D2D1.SolidColorBrush(_renderTarget, Color.White);

            _dwFactory  = new DW.Factory(DW.FactoryType.Shared);
            _textFormat = new DW.TextFormat(_dwFactory, "Arial", DW.FontWeight.Bold,
                                            DW.FontStyle.Normal, DW.FontStretch.Normal, 84 * (float)GraphicsUtils.Scale)
            {
                TextAlignment      = DW.TextAlignment.Center,
                ParagraphAlignment = DW.ParagraphAlignment.Center
            };

            _bitmap = _paradigm.Config.Gui.UseBitmap ? Properties.Resources.Einstein.ToD2D1Bitmap(_renderTarget) : null;
        }
Esempio n. 10
0
        /// <summary>
        /// Find the display mode that most closely matches the requested display mode.
        /// </summary>
        /// <param name="targetProfiles">The target profile, as available formats are different depending on the feature level..</param>
        /// <param name="mode">The mode.</param>
        /// <returns>Returns the closes display mode.</returns>
        /// <unmanaged>HRESULT IDXGIOutput::FindClosestMatchingMode([In] const DXGI_MODE_DESC* pModeToMatch,[Out] DXGI_MODE_DESC* pClosestMatch,[In, Optional] IUnknown* pConcernedDevice)</unmanaged>
        /// <remarks>Direct3D devices require UNORM formats. This method finds the closest matching available display mode to the mode specified in pModeToMatch. Similarly ranked fields (i.e. all specified, or all unspecified, etc) are resolved in the following order.  ScanlineOrdering Scaling Format Resolution RefreshRate  When determining the closest value for a particular field, previously matched fields are used to filter the display mode list choices, and  other fields are ignored. For example, when matching Resolution, the display mode list will have already been filtered by a certain ScanlineOrdering,  Scaling, and Format, while RefreshRate is ignored. This ordering doesn't define the absolute ordering for every usage scenario of FindClosestMatchingMode, because  the application can choose some values initially, effectively changing the order that fields are chosen. Fields of the display mode are matched one at a time, generally in a specified order. If a field is unspecified, FindClosestMatchingMode gravitates toward the values for the desktop related to this output.  If this output is not part of the desktop, then the default desktop output is used to find values. If an application uses a fully unspecified  display mode, FindClosestMatchingMode will typically return a display mode that matches the desktop settings for this output.   Unspecified fields are lower priority than specified fields and will be resolved later than specified fields.</remarks>
        public DisplayMode FindClosestMatchingDisplayMode(GraphicsProfile[] targetProfiles, DisplayMode mode)
        {
            if (targetProfiles == null)
            {
                throw new ArgumentNullException("targetProfiles");
            }

            ModeDescription closestDescription;

            SharpDX.Direct3D12.Device deviceTemp = null;
            for (int i = 0; i < targetProfiles.Length; i++)
            {
                // Create Device D3D12 with feature Level based on profile
                try
                {
                    deviceTemp = new SharpDX.Direct3D12.Device(Adapter.NativeAdapter, (FeatureLevel)targetProfiles[i]);
                    break;
                }
                catch (Exception)
                {
                }
            }

            if (deviceTemp == null)
            {
                throw new InvalidOperationException("Could not create D3D12 graphics device");
            }

            var description = new SharpDX.DXGI.ModeDescription()
            {
                Width            = mode.Width,
                Height           = mode.Height,
                RefreshRate      = mode.RefreshRate.ToSharpDX(),
                Format           = (SharpDX.DXGI.Format)mode.Format,
                Scaling          = DisplayModeScaling.Unspecified,
                ScanlineOrdering = DisplayModeScanlineOrder.Unspecified
            };

            using (var device = deviceTemp)
                output.GetClosestMatchingMode(device, description, out closestDescription);

            return(DisplayMode.FromDescription(closestDescription));
        }
Esempio n. 11
0
        public DeviceResources(IntPtr windowHandle, int renderResWidth, int renderResHeight, int targetFPS)
        {
            Device        = new D3D11.Device(DriverType.Hardware, D3D11.DeviceCreationFlags.Debug | D3D11.DeviceCreationFlags.DisableGpuTimeout);
            DeviceContext = Device.ImmediateContext;


            var backBufferDesc = new DXGI.ModeDescription(
                renderResWidth,
                renderResHeight,
                new DXGI.Rational(targetFPS, 1),
                DXGI.Format.R8G8B8A8_UNorm
                );

            //var backBufferDesc = new DXGI.ModeDescription()
            //{
            //    Width = renderResWidth,
            //    Height = renderResHeight,
            //    RefreshRate = new DXGI.Rational(targetFPS, 1),
            //    Format = DXGI.Format.R8G8B8A8_UNorm
            //};

            var swapChainDesc = new DXGI.SwapChainDescription()
            {
                ModeDescription   = backBufferDesc,
                SampleDescription = sampleDescription,
                Usage             = DXGI.Usage.RenderTargetOutput,
                BufferCount       = 1,
                OutputHandle      = windowHandle,
                IsWindowed        = true
            };

            // Create SwapChain
            DXGI.Factory factory = new DXGI.Factory1();
            SwapChain = new DXGI.SwapChain(factory, Device, swapChainDesc);

            // Create BackBuffer RTV
            BackBuffer    = SwapChain.GetBackBuffer <D3D11.Texture2D>(0);
            BackBufferRTV = new D3D11.RenderTargetView(Device, BackBuffer);
        }
Esempio n. 12
0
        /// <summary>
        /// Find the display mode that most closely matches the requested display mode.
        /// </summary>
        /// <param name="targetProfiles">The target profile, as available formats are different depending on the feature level..</param>
        /// <param name="mode">The mode.</param>
        /// <returns>Returns the closes display mode.</returns>
        /// <unmanaged>HRESULT IDXGIOutput::FindClosestMatchingMode([In] const DXGI_MODE_DESC* pModeToMatch,[Out] DXGI_MODE_DESC* pClosestMatch,[In, Optional] IUnknown* pConcernedDevice)</unmanaged>
        /// <remarks>Direct3D devices require UNORM formats. This method finds the closest matching available display mode to the mode specified in pModeToMatch. Similarly ranked fields (i.e. all specified, or all unspecified, etc) are resolved in the following order.  ScanlineOrdering Scaling Format Resolution RefreshRate  When determining the closest value for a particular field, previously matched fields are used to filter the display mode list choices, and  other fields are ignored. For example, when matching Resolution, the display mode list will have already been filtered by a certain ScanlineOrdering,  Scaling, and Format, while RefreshRate is ignored. This ordering doesn't define the absolute ordering for every usage scenario of FindClosestMatchingMode, because  the application can choose some values initially, effectively changing the order that fields are chosen. Fields of the display mode are matched one at a time, generally in a specified order. If a field is unspecified, FindClosestMatchingMode gravitates toward the values for the desktop related to this output.  If this output is not part of the desktop, then the default desktop output is used to find values. If an application uses a fully unspecified  display mode, FindClosestMatchingMode will typically return a display mode that matches the desktop settings for this output.   Unspecified fields are lower priority than specified fields and will be resolved later than specified fields.</remarks>
        public DisplayMode FindClosestMatchingDisplayMode(GraphicsProfile[] targetProfiles, DisplayMode mode)
        {
            if (targetProfiles == null)
            {
                throw new ArgumentNullException("targetProfiles");
            }

            ModeDescription closestDescription;

            SharpDX.Direct3D11.Device deviceTemp = null;
            try
            {
                var features = new SharpDX.Direct3D.FeatureLevel[targetProfiles.Length];
                for (int i = 0; i < targetProfiles.Length; i++)
                {
                    features[i] = (FeatureLevel)targetProfiles[i];
                }

                deviceTemp = new SharpDX.Direct3D11.Device(adapter.NativeAdapter, SharpDX.Direct3D11.DeviceCreationFlags.None, features);
            }
            catch (Exception) { }

            var description = new SharpDX.DXGI.ModeDescription()
            {
                Width            = mode.Width,
                Height           = mode.Height,
                RefreshRate      = mode.RefreshRate.ToSharpDX(),
                Format           = (SharpDX.DXGI.Format)mode.Format,
                Scaling          = DisplayModeScaling.Unspecified,
                ScanlineOrdering = DisplayModeScanlineOrder.Unspecified
            };

            using (var device = deviceTemp)
                output.GetClosestMatchingMode(device, description, out closestDescription);

            return(DisplayMode.FromDescription(closestDescription));
        }
Esempio n. 13
0
    void InitializeDeviceResources()
    {
        DXGI.ModeDescription      backBufferDesc = new DXGI.ModeDescription(m_width, m_height, new DXGI.Rational(60, 1), DXGI.Format.R8G8B8A8_UNorm);
        DXGI.SwapChainDescription swapChainDesc  = new DXGI.SwapChainDescription()
        {
            ModeDescription   = backBufferDesc,
            SampleDescription = new DXGI.SampleDescription(1, 0),
            Usage             = DXGI.Usage.RenderTargetOutput,
            BufferCount       = 1,
            OutputHandle      = m_renderForm.Handle,
            IsWindowed        = true,
        };
        D3D11.Device.CreateWithSwapChain(SharpDX.Direct3D.DriverType.Hardware, D3D11.DeviceCreationFlags.None, swapChainDesc,
                                         out m_d3d11Device, out m_swapChain);
        m_d3d11DeviceContext = m_d3d11Device.ImmediateContext;

        using (D3D11.Texture2D backBufer = m_swapChain.GetBackBuffer <D3D11.Texture2D>(0))
        {
            m_renderTargetView = new D3D11.RenderTargetView(m_d3d11Device, backBufer);
        }

        m_viewPort = new SharpDX.Viewport(0, 0, m_width, m_height);
        m_d3d11DeviceContext.Rasterizer.SetViewport(m_viewPort);
    }
Esempio n. 14
0
        /// <summary>
        /// Function to update the fullscreen/windowed mode state.
        /// </summary>
        private void ModeStateUpdate()
        {
            var e = new GorgonBeforeStateTransitionEventArgs(!Settings.IsWindowed);

            GI.ModeDescription mode = GorgonVideoMode.Convert(Settings.VideoMode);

            try
            {
                GISwapChain.ResizeTarget(ref mode);

                if (!Settings.IsWindowed)
                {
                    if (BeforeStateTransition != null)
                    {
                        BeforeStateTransition(this, new GorgonBeforeStateTransitionEventArgs(true));
                    }

                    if (!e.Cancel)
                    {
                        // We don't need to force an output.  We'll just let DXGI figure it out from the
                        // window area on the monitor.  Currently SharpDX's ContainingOutput property is
                        // buggy in 2.4.2 and will return multiple ref counts for each time the property is
                        // read.  v2.5.0 is in dev, but now has the problem of not returning the correct output.
                        GISwapChain.SetFullscreenState(true, null);
                        if (_parentForm != null)
                        {
                            _parentForm.Activated  += _parentForm_Activated;
                            _parentForm.Deactivate += _parentForm_Deactivate;
                        }
                    }
                }
                else
                {
                    if (BeforeStateTransition != null)
                    {
                        BeforeStateTransition(this, new GorgonBeforeStateTransitionEventArgs(false));
                    }

                    if (!e.Cancel)
                    {
                        GISwapChain.SetFullscreenState(false, null);
                    }
                }
            }
            catch (SharpDXException sdEx)
            {
                switch (sdEx.ResultCode.Code)
                {
                case (int)GI.DXGIStatus.ModeChangeInProgress:
                    Gorgon.Log.Print("GorgonSwapChain '{0}': Could not switch to full screen mode because the device was busy switching to full screen on another output.", LoggingLevel.All, Name);
                    break;

                default:
                    if (sdEx.ResultCode != GI.ResultCode.NotCurrentlyAvailable)
                    {
                        throw;
                    }

                    Gorgon.Log.Print(
                        "GorgonSwapChain '{0}': Could not switch to full screen mode because the device is not currently available.  Possible causes are:  .",
                        LoggingLevel.All,
                        Name);
                    break;
                }
            }

            ResizeBuffers();

            if ((!e.Cancel) && (AfterStateTransition != null))
            {
                AfterStateTransition(this, new GorgonAfterSwapChainResizedEventArgs(this));
            }
        }
        public void SelectAdapter(int index)
        {
            if (AdapterIndex == index)
                return;

            SelectOutput(-1);

            AdapterIndex = index;
            var count = Factory.GetAdapterCount();
            if (0 <= index && index < count)
            {
                Adapter = Factory.GetAdapter(index);
                using (var device = new Device(Adapter, DeviceCreationFlags.None))
                {
                    SupportedFeatureLevel = device.FeatureLevel;
                }
                Output = null;
                Mode = new ModeDescription();
            }
            else
            {
                Adapter = null;
                SupportedFeatureLevel = null;
                Output = null;
                Mode = new ModeDescription();
            }

            AdapterChanged.InvokeIfNotNull();
            SelectOutput(0);
        }
Esempio n. 16
0
        public DemoApplication()
        {
            //SharpDX.Configuration.EnableObjectTracking = true;

            _Form = new RenderForm();
            _Timer = new Stopwatch();

            _Form.Width = 1280;
            _Form.Height = 720;

            _Form.MaximumSize = new System.Drawing.Size(1280, 720);
            _Form.MinimumSize = new System.Drawing.Size(1280, 720);

            _Form.MaximizeBox = false;
            _Form.SizeGripStyle = SizeGripStyle.Hide;

            _Form.KeyPress += HandleKeyPress;
            _Form.ClientSizeChanged += HandleClientSizeChanged;
            _Form.KeyDown += HandleKeyDown;

            ModeDescription displayMode = new ModeDescription
            {
                Width = _Form.ClientSize.Width,
                Height = _Form.ClientSize.Height,
                RefreshRate = new Rational(60, 1),
                Format = Format.R8G8B8A8_UNorm
            };

            SwapChainDescription chainDescription = new SwapChainDescription
            {
                ModeDescription = displayMode,
                SampleDescription = new SampleDescription(1, 0),
                BufferCount = 2,
                IsWindowed = true,
                OutputHandle = _Form.Handle,
                SwapEffect = SwapEffect.Sequential,
                Usage = Usage.BackBuffer | Usage.RenderTargetOutput
            };

            _Factory = new Factory1();

            int availableAdapters = _Factory.GetAdapterCount1();

            if(availableAdapters == 0)
            {
                throw new Exception("no adapters are available");
            }

            for(int i = 0; i < availableAdapters; ++i)
            {
            #if DEBUG
                using(Adapter1 dxgiSurfaceAdapter = _Factory.GetAdapter1(i))
                {
                    try
                    {
                    Device1.CreateWithSwapChain(
                        dxgiSurfaceAdapter,
                        DeviceCreationFlags.BgraSupport | DeviceCreationFlags.Debug,
                        chainDescription,
                        out _Device,
                        out _SwapChain);
                    }
                    catch(SharpDXException)
                    {
                        continue;
                    }

                    _Device2D = new Device2D(dxgiSurfaceAdapter);
                }
            #else
                using (Adapter1 dxgiSurfaceAdapter = _Factory.GetAdapter1(i))
                {
                    try
                    {
                        Device1.CreateWithSwapChain(
                            dxgiSurfaceAdapter,
                            DeviceCreationFlags.BgraSupport,
                            chainDescription,
                            out _Device,
                            out _SwapChain);

                    }
                    catch(SharpDXException)
                    {
                        continue;
                    }

                    _Device2D = new Device2D(dxgiSurfaceAdapter);
                }
            #endif
            }

            _Device2D.Diagnostics.Query("Composition", "FrameBatchCount", out _CompositionFrameBatchCount);
            _Device2D.Diagnostics.Query("Composition", "FrameDuration", out _CompositionFrameDuration);
            _Device2D.Diagnostics.Query("Painting", "FrameDuration", out _PaintingFrameDuration);

            _Timer.Start();

            _Renderer = new D3D10Renderer(_Device);

            HandleClientSizeChanged(null, null);

            _IsResetQueued = true;
        }
Esempio n. 17
0
 /// <summary>
 /// Converts between a DXGI mode description and a GorgonVideoMode.
 /// </summary>
 /// <param name="mode">The mode to convert.</param>
 /// <returns>The DXGI mode.</returns>
 internal static GorgonVideoMode Convert(GI.ModeDescription mode)
 {
     return(new GorgonVideoMode(mode.Width, mode.Height, (BufferFormat)mode.Format, mode.RefreshRate.Numerator, mode.RefreshRate.Denominator));
 }
        internal static void RestoreFullscreenMode()
        {
            if (!m_changeToFullscreen.HasValue)
            {
                if (!m_swapchain.IsFullScreen && m_settings.WindowMode == MyWindowModeEnum.Fullscreen)
                {
                    ModeDescription md = new ModeDescription();
                    md.Format = MyRender11Constants.BACKBUFFER_FORMAT;
                    md.Height = m_settings.BackBufferHeight;
                    md.Width = m_settings.BackBufferWidth;
                    md.Scaling = DisplayModeScaling.Unspecified;
                    md.ScanlineOrdering = DisplayModeScanlineOrder.Progressive;
                    md.RefreshRate.Numerator = m_settings.RefreshRate;
                    md.RefreshRate.Denominator = 1000;

                    var list = m_adapterModes[m_settings.AdapterOrdinal];
                    if (list != null)
                    {
                        for (int i = 0; i < list.Length; i++)
                        {
                            if (
                                list[i].Height == m_settings.BackBufferHeight &&
                                list[i].Width == m_settings.BackBufferWidth &&
                                list[i].RefreshRate.Numerator == m_settings.RefreshRate)
                            {
                                md.Scaling = list[i].Scaling;
                                md.ScanlineOrdering = list[i].ScanlineOrdering;
                                md.RefreshRate = list[i].RefreshRate;
                                break;
                            }
                        }
                    }

                    m_changeToFullscreen = md;
                }
            }
        }
        public SwapChainDescription CreateSwapChain(int PBufferCount, Usage PUsage, IntPtr PFormHandle, bool PIsWindowed, int PModeDescriptionWidth, int PModeDescriptionHeight, Rational PModeDescriptionRefreshRate, Format PModeDescriptionFormat, int PSampleDescriptionCount, int PSampleDescriptionQuality, SwapChainFlags PSwapChainFlags, SwapEffect PSwapEffect)
        {
            this._BufferCount = PBufferCount;
            this._Usage = PUsage;
            this._FormHandle = PFormHandle;
            this._IsWindowed = PIsWindowed;
            this._ModeDescriptionWidth = PModeDescriptionWidth;
            this._ModeDescriptionHeight = PModeDescriptionHeight;
            this._ModeDescriptionRefreshRate = PModeDescriptionRefreshRate;
            this._ModeDescriptionFormat = PModeDescriptionFormat;
            this._SampleDescriptionCount = PSampleDescriptionCount;
            this._SampleDescriptionQuality = PSampleDescriptionQuality;
            this._SwapChainFlags = PSwapChainFlags;
            this._SwapEffect = PSwapEffect;
            _SampleDescription = new SampleDescription(_SampleDescriptionCount, _SampleDescriptionQuality);
            _ModeDescription = new ModeDescription(_ModeDescriptionWidth, _ModeDescriptionHeight, _ModeDescriptionRefreshRate, _ModeDescriptionFormat);
            _SwapChainDesc = new SwapChainDescription() {
                BufferCount = _BufferCount,
                Usage=_Usage,
                OutputHandle=_FormHandle,
                IsWindowed=_IsWindowed,
                ModeDescription=_ModeDescription,
                SampleDescription=_SampleDescription,
                Flags=_SwapChainFlags,
                SwapEffect=_SwapEffect };

            return _SwapChainDesc;
        }
Esempio n. 20
0
        /// <summary>
        /// Creates Direct3D11 Device, RenderTargetView, DepthStencilView, Viewport
        /// </summary>
        /// <param name="deviceDescription">The device description.</param>
        /// <exception cref="System.Exception"></exception>
        /// <exception cref="System.ComponentModel.InvalidEnumArgumentException">deviceDescription.MultiSampleCount</exception>
        private void Initialize(DeviceDescription deviceDescription)
        {
            FeatureLevel[] levels = new FeatureLevel[] {
                FeatureLevel.Level_10_0,
                FeatureLevel.Level_10_1,
                FeatureLevel.Level_11_0,
                FeatureLevel.Level_11_1,
            };

            d3dDevice = new D3D11.Device(DriverType.Hardware, D3D11.DeviceCreationFlags.Debug, levels);

            DXGI.ModeDescription backBufferDesc = new DXGI.ModeDescription()
            {
                Width            = width,
                Height           = height,
                Format           = BackBufferFormat,
                RefreshRate      = new DXGI.Rational(60, 1),
                Scaling          = DXGI.DisplayModeScaling.Unspecified,
                ScanlineOrdering = DXGI.DisplayModeScanlineOrder.Progressive,
            };

            DXGI.SwapChainDescription swapChainDesc = new DXGI.SwapChainDescription()
            {
                BufferCount     = 1,
                Flags           = DXGI.SwapChainFlags.None,
                IsWindowed      = !deviceDescription.Fullcreen,
                ModeDescription = backBufferDesc,
                OutputHandle    = renderControl.Handle,
                SwapEffect      = deviceDescription.SwapEffect,
                Usage           = DXGI.Usage.RenderTargetOutput,
            };

            switch (deviceDescription.MultiSampleCount)
            {
            case MultiSampleType.MSAA1:
                swapChainDesc.SampleDescription = new DXGI.SampleDescription(1, deviceDescription.MultiSampleQuality);
                break;

            case MultiSampleType.MSAA2:
                swapChainDesc.SampleDescription = new DXGI.SampleDescription(2, deviceDescription.MultiSampleQuality);
                break;

            case MultiSampleType.MSAA4:
                swapChainDesc.SampleDescription = new DXGI.SampleDescription(4, deviceDescription.MultiSampleQuality);
                break;

            case MultiSampleType.MSAA8:
                swapChainDesc.SampleDescription = new DXGI.SampleDescription(8, deviceDescription.MultiSampleQuality);
                break;

            case MultiSampleType.MSAA16:
                swapChainDesc.SampleDescription = new DXGI.SampleDescription(16, deviceDescription.MultiSampleQuality);
                break;

            case MultiSampleType.Unknown:
                var samples = SharpDXDevice.CheckMultiSample();
                if (samples == null)
                {
                    throw new Exception(MethodBase.GetCurrentMethod().Name +
                                        " Because the MultiSampleCount parameter is [Unknown], the device could not determine the parameter automatically");
                }
                swapChainDesc.SampleDescription = samples.Last();
                break;

            default:
                throw new System.ComponentModel.InvalidEnumArgumentException("deviceDescription.MultiSampleCount",
                                                                             (int)deviceDescription.MultiSampleCount, typeof(MultiSampleType));
            }

            DXGI.Device  device  = d3dDevice.QueryInterface <DXGI.Device>();
            DXGI.Adapter adapter = device.GetParent <DXGI.Adapter>();
            DXGI.Factory factory = adapter.GetParent <DXGI.Factory>();

            swapChain = new DXGI.SwapChain(factory, d3dDevice, swapChainDesc);

            d3dContext = d3dDevice.ImmediateContext;

            D3D11.RasterizerStateDescription rasterDesc = new D3D11.RasterizerStateDescription()
            {
                CullMode = D3D11.CullMode.Back,
                FillMode = D3D11.FillMode.Solid,
                IsAntialiasedLineEnabled = true,
                IsMultisampleEnabled     = true,
                IsDepthClipEnabled       = true,
            };

            viewport = new Viewport(0, 0, width, height);

            this.SetRasterizerState(rasterDesc);
            d3dRenderTarget = CreateRenderTarget();
            d3dDepthStencil = CreateDepthStencil();
        }
Esempio n. 21
0
        /// <summary>
        ///     Hooked to allow resizing a texture/surface that is reused. Currently not in use as we create the texture for each
        ///     request
        ///     to support different sizes each time (as we use DirectX to copy only the region we are after rather than the entire
        ///     backbuffer)
        /// </summary>
        /// <param name="swapChainPtr"></param>
        /// <param name="newTargetParameters"></param>
        /// <returns></returns>
        private int ResizeTargetHook(IntPtr swapChainPtr, ref ModeDescription newTargetParameters)
        {
            var swapChain = (SwapChain) swapChainPtr;
            //using (SharpDX.DXGI.SwapChain swapChain = SharpDX.DXGI.SwapChain.FromPointer(swapChainPtr))
            {
                // This version creates a new texture for each request so there is nothing to resize.
                // IF the size of the texture is known each time, we could create it once, and then possibly need to resize it here

                swapChain.ResizeTarget(ref newTargetParameters);
                return Result.Ok.Code;
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Initializes a new engine, sets view , tex manager
        /// camera , mesh manager , texture manager , line manager
        /// volume manager
        /// </summary>
        /// <param name="width">The width of the Render target</param>
        /// <param name="height">The height of the Render target</param>
        public Engine(int Width, int Height, Form form)
        {
            // pass the settings of resolution
            Settings.Resolution = new System.Drawing.Size(Width, Height);

            /// set the handles for full screen or windows
            this.form = form;
            this.FormHandle = form.Handle;

            /// Create the factory which manages general graphics resources
            g_factory = new Factory();
            g_factory.MakeWindowAssociation(this.FormHandle, WindowAssociationFlags.IgnoreAll);

            // find correct adapter
            int adapterCount = g_factory.GetAdapterCount();
            //MessageBox.Show(adapterCount.ToString());

            // we try to select the PerfHUD adapter
            for (int i = 0; i < adapterCount; i++)
            {
                Adapter adapt = g_factory.GetAdapter(i);
                //MessageBox.Show(adapt.Description.Description);

                if (adapt.Description.Description == "NVIDIA PerfHUD")
                {
                    g_device = new Device(
                        adapt,
                        DeviceCreationFlags.Debug);
                }

                Console.WriteLine(i.ToString() + adapt.Description.Description);
            }

            if (g_device == null)
            {

            #if true
                /// Create the DirectX Device
                g_device = new Device(g_factory.GetAdapter(1),
                                      (Settings.Debug) ? DeviceCreationFlags.Debug : DeviceCreationFlags.None,
                                      new FeatureLevel[] { FeatureLevel.Level_11_0 });

            #else
                g_device = new Device(DriverType.Warp,
                                        (Settings.Debug) ? DeviceCreationFlags.Debug : DeviceCreationFlags.None,
                                        new FeatureLevel[] { FeatureLevel.Level_11_0 });
            #endif

                // check if we have one device to our system
                if (!(((g_device.FeatureLevel & FeatureLevel.Level_10_0) != 0) || ((g_device.FeatureLevel & FeatureLevel.Level_10_1) != 0) || ((g_device.FeatureLevel & FeatureLevel.Level_11_0) != 0)))
                {
                    // if we don't have we just simulate
                    #region Create the device base on swapChain
                    /// Create a description of the display mode
                    g_modeDesc = new ModeDescription();
                    /// Standard 32-bit RGBA
                    g_modeDesc.Format = Format.R8G8B8A8_UNorm;
                    /// Refresh rate of 60Hz (60 / 1 = 60)
                    g_modeDesc.RefreshRate = new Rational(60, 1);
                    /// Default
                    g_modeDesc.Scaling = DisplayModeScaling.Unspecified;
                    g_modeDesc.ScanlineOrdering = DisplayModeScanlineOrder.Progressive;

                    /// ClientSize is the size of the
                    /// form without the title and borders
                    g_modeDesc.Width = Width;
                    g_modeDesc.Height = Height;

                    /// Create a description of the samping
                    /// for multisampling or antialiasing
                    g_sampleDesc = new SampleDescription();
                    /// No multisampling
                    g_sampleDesc.Count = 1;
                    g_sampleDesc.Quality = 0;

                    /// Create a description of the swap
                    /// chain or front and back buffers
                    g_swapDesc = new SwapChainDescription();
                    /// link the ModeDescription
                    g_swapDesc.ModeDescription = g_modeDesc;
                    /// link the SampleDescription
                    g_swapDesc.SampleDescription = g_sampleDesc;
                    /// Number of buffers (including the front buffer)
                    g_swapDesc.BufferCount = 1;
                    g_swapDesc.Flags = SwapChainFlags.AllowModeSwitch;
                    g_swapDesc.IsWindowed = true;
                    /// The output window (the windows being rendered to)
                    g_swapDesc.OutputHandle = this.FormHandle;
                    /// Scrap the contents of the buffer every frame
                    g_swapDesc.SwapEffect = SwapEffect.Discard;
                    /// Indicate that this SwapChain
                    /// is going to be a Render target
                    g_swapDesc.Usage = Usage.RenderTargetOutput;

                    //g_swapChain = new SwapChain(g_factory, g_device, g_swapDesc);

                    try
                    {
                        /// Create the actual swap chain
                        /// Here we set and the device type
                        Device.CreateWithSwapChain(DriverType.Warp, (Settings.Debug) ? DeviceCreationFlags.Debug : DeviceCreationFlags.None, new FeatureLevel[] { Settings.FeatureLevel }, g_swapDesc, out g_device, out g_swapChain);
                    }
                    catch (Exception ex)
                    {
                        /// Create the actual swap chain
                        /// Here we set and the device type
                        Device.CreateWithSwapChain(DriverType.Reference, (Settings.Debug) ? DeviceCreationFlags.Debug : DeviceCreationFlags.None, new FeatureLevel[] { Settings.FeatureLevel }, g_swapDesc, out g_device, out g_swapChain);
                    }

                    /// Create the factory which manages general graphics resources
                    g_factory = g_swapChain.GetParent<Factory>();

                    g_factory.MakeWindowAssociation(this.FormHandle, WindowAssociationFlags.IgnoreAll);
                    #endregion
                }
                else
                {
            #if false

                    #region Create the device base on swapChain
                    /// Create a description of the display mode
                    g_modeDesc = new ModeDescription();
                    /// Standard 32-bit RGBA
                    g_modeDesc.Format = Format.R8G8B8A8_UNorm;
                    /// Refresh rate of 60Hz (60 / 1 = 60)
                    g_modeDesc.RefreshRate = new Rational(60, 1);
                    /// Default
                    g_modeDesc.Scaling = DisplayModeScaling.Unspecified;
                    g_modeDesc.ScanlineOrdering = DisplayModeScanlineOrdering.Progressive;

                    /// ClientSize is the size of the
                    /// form without the title and borders
                    g_modeDesc.Width = Width;
                    g_modeDesc.Height = Height;

                    /// Create a description of the samping
                    /// for multisampling or antialiasing
                    g_sampleDesc = new SampleDescription();
                    /// No multisampling
                    g_sampleDesc.Count = 1;
                    g_sampleDesc.Quality = 0;

                    /// Create a description of the swap
                    /// chain or front and back buffers
                    g_swapDesc = new SwapChainDescription();
                    /// link the ModeDescription
                    g_swapDesc.ModeDescription = g_modeDesc;
                    /// link the SampleDescription
                    g_swapDesc.SampleDescription = g_sampleDesc;
                    /// Number of buffers (including the front buffer)
                    g_swapDesc.BufferCount = 1;
                    g_swapDesc.Flags = SwapChainFlags.None;
                    g_swapDesc.IsWindowed = true;
                    /// The output window (the windows being rendered to)
                    g_swapDesc.OutputHandle = FormHandle;
                    /// Scrap the contents of the buffer every frame
                    g_swapDesc.SwapEffect = SwapEffect.Discard;
                    /// Indicate that this SwapChain
                    /// is going to be a Render target
                    g_swapDesc.Usage = Usage.RenderTargetOutput;

                    g_swapChain = new SwapChain(g_factory, g_device, g_swapDesc);

                    #endregion
            #endif
                }

                // set the feature level
                Settings.FeatureLevel = g_device.FeatureLevel;
            }

            /// init mesh manager
            g_MeshManager = new Object3DManager();

            /// init deferred device
            //DeferredDev1 = new DeviceContext( Engine.g_device );
            //DeferredDev2 = new DeviceContext( Engine.g_device );

            // init the image factory...
            g_image_factory = new ImagingFactory();

            /// Set flag to indicate that engine is running
            g_Running = true;

            Logger.WriteLine("The Graphing Engine have be start ");

            // set the event handler
            RenderLoopHandler = new EventHandler(RenderLoop);

            var rtb = new RenderTargetBlendDescription()
            {
                IsBlendEnabled = true,
                BlendOperation = BlendOperation.Add,
                AlphaBlendOperation = BlendOperation.Add,
                DestinationBlend = BlendOption.One,
                DestinationAlphaBlend = BlendOption.Zero,
                SourceBlend = BlendOption.One,
                SourceAlphaBlend = BlendOption.One,
                RenderTargetWriteMask = ColorWriteMaskFlags.All
            };

            BlendStateDescription blendDesc = new BlendStateDescription();
            blendDesc.AlphaToCoverageEnable = false;
            blendDesc.IndependentBlendEnable = false;
            blendDesc.RenderTarget[0] = rtb;

            g_blendState = new BlendState(g_device, blendDesc);

            DepthStencilStateDescription dssd = new DepthStencilStateDescription();
            dssd.DepthComparison = Comparison.Less;
            dssd.IsDepthEnabled = true;
            g_depthStencilState = new DepthStencilState(g_device, new DepthStencilStateDescription());
        }
        public void SelectMode(int index)
        {
            if (ModeIndex == index)
                return;

            var modes = GetDisplayModes();
            var count = modes.Length;
            if (0 <= index && index < count)
            {
                ModeIndex = index;
                Mode = modes[index];
            }
            else
            {
                ModeIndex = -1;
                Mode = new ModeDescription();
            }

            ModeChanged.InvokeIfNotNull();
        }
Esempio n. 24
0
 internal DisplayMode(ModeDescription modeDescription)
 {
     this.modeDescription = modeDescription;
 }
        /// <summary>
        /// Find the display mode that most closely matches the requested display mode.
        /// </summary>
        /// <param name="targetProfiles">The target profile, as available formats are different depending on the feature level..</param>
        /// <param name="mode">The mode.</param>
        /// <returns>Returns the closes display mode.</returns>
        /// <unmanaged>HRESULT IDXGIOutput::FindClosestMatchingMode([In] const DXGI_MODE_DESC* pModeToMatch,[Out] DXGI_MODE_DESC* pClosestMatch,[In, Optional] IUnknown* pConcernedDevice)</unmanaged>
        /// <remarks>Direct3D devices require UNORM formats. This method finds the closest matching available display mode to the mode specified in pModeToMatch. Similarly ranked fields (i.e. all specified, or all unspecified, etc) are resolved in the following order.  ScanlineOrdering Scaling Format Resolution RefreshRate  When determining the closest value for a particular field, previously matched fields are used to filter the display mode list choices, and  other fields are ignored. For example, when matching Resolution, the display mode list will have already been filtered by a certain ScanlineOrdering,  Scaling, and Format, while RefreshRate is ignored. This ordering doesn't define the absolute ordering for every usage scenario of FindClosestMatchingMode, because  the application can choose some values initially, effectively changing the order that fields are chosen. Fields of the display mode are matched one at a time, generally in a specified order. If a field is unspecified, FindClosestMatchingMode gravitates toward the values for the desktop related to this output.  If this output is not part of the desktop, then the default desktop output is used to find values. If an application uses a fully unspecified  display mode, FindClosestMatchingMode will typically return a display mode that matches the desktop settings for this output.   Unspecified fields are lower priority than specified fields and will be resolved later than specified fields.</remarks>
        public DisplayMode FindClosestMatchingDisplayMode(GraphicsProfile[] targetProfiles, DisplayMode mode)
        {
            if (targetProfiles == null) throw new ArgumentNullException("targetProfiles");

            ModeDescription closestDescription;
            SharpDX.Direct3D12.Device deviceTemp = null;
            for (int i = 0; i < targetProfiles.Length; i++)
            {
                // Create Device D3D12 with feature Level based on profile
                try
                {
                    deviceTemp = new SharpDX.Direct3D12.Device(Adapter.NativeAdapter, (FeatureLevel)targetProfiles[i]);
                    break;
                }
                catch (Exception)
                {
                }
            }

            if (deviceTemp == null)
                throw new InvalidOperationException("Could not create D3D12 graphics device");

            var description = new SharpDX.DXGI.ModeDescription()
            {
                Width = mode.Width,
                Height = mode.Height,
                RefreshRate = mode.RefreshRate.ToSharpDX(),
                Format = (SharpDX.DXGI.Format)mode.Format,
                Scaling = DisplayModeScaling.Unspecified,
                ScanlineOrdering = DisplayModeScanlineOrder.Unspecified
            };
            using (var device = deviceTemp)
                output.GetClosestMatchingMode(device, description, out closestDescription);

            return DisplayMode.FromDescription(closestDescription);
        }
Esempio n. 26
0
        private void SetView(int Width, int Height)
        {
            ///////////////////////////////////////////////////////////////////////// Set the ModeDescription
            /// Create a description of the display mode
            m_ModeDesc = new ModeDescription();

            /// Standard 32-bit RGBA
            m_ModeDesc.Format = backFormat;

            /// Refresh rate of 60Hz (60 / 1 = 60)
            m_ModeDesc.RefreshRate = new Rational(Settings.FrameRate, 1);

            /// Default
            m_ModeDesc.Scaling = DisplayModeScaling.Centered;
            m_ModeDesc.ScanlineOrdering =  DisplayModeScanlineOrder.Progressive;

            /// ClientSize is the size of the
            /// form without the title and borders
            m_ModeDesc.Width = Width;
            m_ModeDesc.Height = Height;

            ///////////////////////////////////////////////////////////////////////// Set the SampleDescription

            /// Create a description of the sampling
            /// for multisampling or antialiasing
            m_SampleDesc = new SampleDescription();

            /// No multisampling
            m_SampleDesc.Count = 1;
            m_SampleDesc.Quality = 0;

            ///////////////////////////////////////////////////////////////////////// Set the SampleDescription

            /// Create a description of the swap
            /// chain or front and back buffers
            m_SwapDesc = new SwapChainDescription();

            /// link the ModeDescription
            m_SwapDesc.ModeDescription = m_ModeDesc;

            /// link the SampleDescription
            m_SwapDesc.SampleDescription = m_SampleDesc;

            /// Number of buffers (including the front buffer)
            m_SwapDesc.BufferCount = 1;
            m_SwapDesc.Flags = SwapChainFlags.None;
            m_SwapDesc.IsWindowed = true;

            /// The output window (the windows being rendered to)
            m_SwapDesc.OutputHandle = this.m_RenderControl;

            /// Scrap the contents of the buffer every frame
            m_SwapDesc.SwapEffect = SwapEffect.Discard;

            /// Indicate that this SwapChain
            /// is going to be a Render target
            m_SwapDesc.Usage = Usage.RenderTargetOutput;

            ///////////////////////////////////////////////////////////////////////// Create Chain

            // release the old chain
            if (m_SwapChain != null)
                m_SwapChain.Dispose();

            /// Create the actual swap chain
            m_SwapChain = new SwapChain(Engine.g_factory, Engine.g_device, m_SwapDesc);

            ///////////////////////////////////////////////////////////////////////// Set the Render Target

            m_RenderStencil = Texture2D.FromSwapChain<Texture2D>(m_SwapChain, 0);

            /// Create and set the Render target -
            /// the surface that we're actually going to draw on
            m_RenderTarget = new RenderTargetView(
                Engine.g_device, m_RenderStencil);

            ///////////////////////////////////////////////////////////////////////// Set the m_DepthStencil and m_DepthStencilView

            /// Create depth stencil texture
            /// and setup its settings
            Texture2DDescription descDepth = new Texture2DDescription();
            descDepth.Width = Width;
            descDepth.Height = Height;
            descDepth.MipLevels = 1;
            descDepth.ArraySize = 1;
            descDepth.Format = Format.D32_Float;
            descDepth.SampleDescription = new SampleDescription(1, 0);
            descDepth.Usage = ResourceUsage.Default;
            descDepth.BindFlags = BindFlags.DepthStencil;
            descDepth.CpuAccessFlags = CpuAccessFlags.None;
            descDepth.OptionFlags = ResourceOptionFlags.None;

            /// create the depth stencil view
            /// and setup its settings
            DepthStencilViewDescription descDSV = new DepthStencilViewDescription();
            descDSV.Format = descDepth.Format;
            descDSV.Dimension = DepthStencilViewDimension.Texture2D;
            //descDSV.MipSlice = 0;

            m_DepthStencil = new Texture2D(Engine.g_device, descDepth);
            m_DepthStencilView = new DepthStencilView(Engine.g_device, m_DepthStencil, descDSV);
        }
Esempio n. 27
0
        /// <summary>
        /// Find the display mode that most closely matches the requested display mode.
        /// </summary>
        /// <param name="targetProfiles">The target profile, as available formats are different depending on the feature level..</param>
        /// <param name="mode">The mode.</param>
        /// <returns>Returns the closes display mode.</returns>
        /// <unmanaged>HRESULT IDXGIOutput::FindClosestMatchingMode([In] const DXGI_MODE_DESC* pModeToMatch,[Out] DXGI_MODE_DESC* pClosestMatch,[In, Optional] IUnknown* pConcernedDevice)</unmanaged>
        /// <remarks>Direct3D devices require UNORM formats. This method finds the closest matching available display mode to the mode specified in pModeToMatch. Similarly ranked fields (i.e. all specified, or all unspecified, etc) are resolved in the following order.  ScanlineOrdering Scaling Format Resolution RefreshRate  When determining the closest value for a particular field, previously matched fields are used to filter the display mode list choices, and  other fields are ignored. For example, when matching Resolution, the display mode list will have already been filtered by a certain ScanlineOrdering,  Scaling, and Format, while RefreshRate is ignored. This ordering doesn't define the absolute ordering for every usage scenario of FindClosestMatchingMode, because  the application can choose some values initially, effectively changing the order that fields are chosen. Fields of the display mode are matched one at a time, generally in a specified order. If a field is unspecified, FindClosestMatchingMode gravitates toward the values for the desktop related to this output.  If this output is not part of the desktop, then the default desktop output is used to find values. If an application uses a fully unspecified  display mode, FindClosestMatchingMode will typically return a display mode that matches the desktop settings for this output.   Unspecified fields are lower priority than specified fields and will be resolved later than specified fields.</remarks>
        public DisplayMode FindClosestMatchingDisplayMode(FeatureLevel[] targetProfiles,  DisplayMode mode)
        {
            ModeDescription closestDescription;
            SharpDX.Direct3D11.Device deviceTemp = null;
            try
            {
                deviceTemp = new SharpDX.Direct3D11.Device(adapter, DeviceCreationFlags.None, targetProfiles);
            }
            catch(Exception ex) {}

            var descriprtion = new ModeDescription()
                                   {
                                       Width = mode.Width,
                                       Height = mode.Height,
                                       RefreshRate = mode.RefreshRate,
                                       Format = mode.Format,
                                       Scaling = DisplayModeScaling.Unspecified,
                                       ScanlineOrdering = DisplayModeScanlineOrder.Unspecified
                                   };
            using (var device = deviceTemp)
                output.GetClosestMatchingMode(device, descriprtion, out closestDescription);

            return DisplayMode.FromDescription(closestDescription);
        }
Esempio n. 28
0
        int ResizeTarget(IntPtr swapChainPtr, ref ModeDescription dwTargetParams)
        {
            SwapChain swapChain = (SwapChain)swapChainPtr;
            {

                if (_overlay != null) {
                    _overlay.Dispose();
                    _overlay = null;
                }
                swapChain.ResizeTarget(ref dwTargetParams);
                return Result.Ok.Code;
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Hooked to allow resizing a texture/surface that is reused. Currently not in use as we create the texture for each request
        /// to support different sizes each time (as we use DirectX to copy only the region we are after rather than the entire backbuffer)
        /// </summary>
        /// <param name="swapChainPtr"></param>
        /// <param name="newTargetParameters"></param>
        /// <returns></returns>
        int ResizeTargetHook(IntPtr swapChainPtr, ref ModeDescription newTargetParameters)
        {
            SwapChain swapChain = (SharpDX.DXGI.SwapChain)swapChainPtr;
            //using (SharpDX.DXGI.SwapChain swapChain = SharpDX.DXGI.SwapChain.FromPointer(swapChainPtr))
            {
                // This version creates a new texture for each request so there is nothing to resize.
                // IF the size of the texture is known each time, we could create it once, and then possibly need to resize it here

                // Dispose of overlay engine (so it will be recreated)
#if OVERLAYENGINE
                if (_overlayEngine != null)
                {
                    _overlayEngine.Dispose();
                    _overlayEngine = null;
                }
#endif

                swapChain.ResizeTarget(ref newTargetParameters);
                return SharpDX.Result.Ok.Code;
            }
        }
Esempio n. 30
0
 internal static void FixModeDescriptionForFullscreen(ref ModeDescription md)
 {
     var list = m_adapterModes.Get(m_settings.AdapterOrdinal);
     if (list != null)
     {
         for (int i = 0; i < list.Length; i++)
         {
             if (
                 list[i].Height == m_settings.BackBufferHeight &&
                 list[i].Width == m_settings.BackBufferWidth &&
                 list[i].RefreshRate.Numerator == m_settings.RefreshRate)
             {
                 md.Scaling = list[i].Scaling;
                 md.ScanlineOrdering = list[i].ScanlineOrdering;
                 md.RefreshRate = list[i].RefreshRate;
                 break;
             }
         }
     }
 }
        public void SelectOutput(int index)
        {
            if (OutputIndex == index)
                return;

            SelectMode(-1);

            var count = Adapter.GetOutputCount();
            if (0 <= index && index < count)
            {
                OutputIndex = index;
                Output = Adapter.GetOutput(index);
                Mode = new ModeDescription();
            }
            else
            {
                OutputIndex = -1;
                Output = null;
                Mode = new ModeDescription();
            }

            OutputChanged.InvokeIfNotNull();
            SelectMode(0);
        }
Esempio n. 32
0
        internal static void RestoreFullscreenMode()
        {
            if (!m_changeToFullscreen.HasValue)
            {
                if (!m_swapchain.IsFullScreen && m_settings.WindowMode == MyWindowModeEnum.Fullscreen)
                {
                    ModeDescription md = new ModeDescription();
                    md.Format = MyRender11Constants.BACKBUFFER_FORMAT;
                    md.Height = m_settings.BackBufferHeight;
                    md.Width = m_settings.BackBufferWidth;
                    md.Scaling = DisplayModeScaling.Unspecified;
                    md.ScanlineOrdering = DisplayModeScanlineOrder.Progressive;
                    md.RefreshRate.Numerator = m_settings.RefreshRate;
                    md.RefreshRate.Denominator = 1000;

                    FixModeDescriptionForFullscreen(ref md);

                    m_changeToFullscreen = md;
                }
            }
        }
        public bool TrySelectMode(ModeDescription mode)
        {
            var modes = GetDisplayModes();
            var matchingIndices = Enumerable
                .Range(0, modes.Length)
                .Where(i => mode.Equals(modes[i]))
                .ToArray();
            if (matchingIndices.Length != 1)
                return false;

            SelectMode(matchingIndices[0]);
            return true;
        }
Esempio n. 34
0
        internal static void ApplySettings(MyRenderDeviceSettings settings)
        {
            MyRender11.Log.WriteLine("ApplySettings");
            MyRender11.Log.IncreaseIndent();

            //bool differentAdapter = m_adapterInfoList[m_settings.AdapterOrdinal].AdapterDeviceId != m_adapterInfoList[settings.AdapterOrdinal].AdapterDeviceId;

            //if (differentAdapter)
            //{
            //    m_settings = settings;
            //    HandleDeviceReset();
            //}
            //else
            //{
            LogSettings(ref settings);

            CommandsListsSupported = m_adapterInfoList[m_settings.AdapterOrdinal].MultithreadedRenderingSupported;
            IsIntelBrokenCubemapsWorkaround = m_adapterInfoList[m_settings.AdapterOrdinal].Priority == 1; // 1 is intel

            bool deviceRemoved = false;

            try
            {
                ResizeSwapchain(settings.BackBufferWidth, settings.BackBufferHeight);
            }
            catch(SharpDXException e)
            {
                if (e.Descriptor == SharpDX.DXGI.ResultCode.DeviceRemoved && Device.DeviceRemovedReason == SharpDX.DXGI.ResultCode.DeviceRemoved)
                {
                    deviceRemoved = true;
                    MyRender11.Log.WriteLine("Device removed - resetting device");
                    HandleDeviceReset();
                    MyRender11.Log.WriteLine("Device removed - resetting completed");
                }
            }

            if(!deviceRemoved)
            {
                ModeDescription md = new ModeDescription();
                md.Format = MyRender11Constants.BACKBUFFER_FORMAT;
                md.Height = settings.BackBufferHeight;
                md.Width = settings.BackBufferWidth;
                md.Scaling = DisplayModeScaling.Unspecified;
                md.ScanlineOrdering = DisplayModeScanlineOrder.Progressive;
                md.RefreshRate.Numerator = 60000;
                md.RefreshRate.Denominator = 1000;

                FixModeDescriptionForFullscreen(ref md);

                // to fullscreen
                if (settings.WindowMode == MyWindowModeEnum.Fullscreen)
                {
                    if (settings.WindowMode != m_settings.WindowMode)
                    {
                        m_changeToFullscreen = md;
                    }
                    else
                    {
                        m_swapchain.ResizeTarget(ref md);
                        md.RefreshRate.Denominator = 0;
                        md.RefreshRate.Numerator = 0;
                        m_swapchain.ResizeTarget(ref md);
                    }
                }
                // from fullscreen
                else if (settings.WindowMode != m_settings.WindowMode && m_settings.WindowMode == MyWindowModeEnum.Fullscreen)
                {
                    m_swapchain.ResizeTarget(ref md);
                    m_swapchain.SetFullscreenState(false, null);
                }

                m_settings = settings;

                TryChangeToFullscreen();
            }

            MyRender11.Log.DecreaseIndent();
        }
        /// <summary>
        /// Find the display mode that most closely matches the requested display mode.
        /// </summary>
        /// <param name="targetProfiles">The target profile, as available formats are different depending on the feature level..</param>
        /// <param name="mode">The mode.</param>
        /// <returns>Returns the closes display mode.</returns>
        /// <unmanaged>HRESULT IDXGIOutput::FindClosestMatchingMode([In] const DXGI_MODE_DESC* pModeToMatch,[Out] DXGI_MODE_DESC* pClosestMatch,[In, Optional] IUnknown* pConcernedDevice)</unmanaged>
        /// <remarks>Direct3D devices require UNORM formats. This method finds the closest matching available display mode to the mode specified in pModeToMatch. Similarly ranked fields (i.e. all specified, or all unspecified, etc) are resolved in the following order.  ScanlineOrdering Scaling Format Resolution RefreshRate  When determining the closest value for a particular field, previously matched fields are used to filter the display mode list choices, and  other fields are ignored. For example, when matching Resolution, the display mode list will have already been filtered by a certain ScanlineOrdering,  Scaling, and Format, while RefreshRate is ignored. This ordering doesn't define the absolute ordering for every usage scenario of FindClosestMatchingMode, because  the application can choose some values initially, effectively changing the order that fields are chosen. Fields of the display mode are matched one at a time, generally in a specified order. If a field is unspecified, FindClosestMatchingMode gravitates toward the values for the desktop related to this output.  If this output is not part of the desktop, then the default desktop output is used to find values. If an application uses a fully unspecified  display mode, FindClosestMatchingMode will typically return a display mode that matches the desktop settings for this output.   Unspecified fields are lower priority than specified fields and will be resolved later than specified fields.</remarks>
        public DisplayMode FindClosestMatchingDisplayMode(GraphicsProfile[] targetProfiles, DisplayMode mode)
        {
            if (targetProfiles == null) throw new ArgumentNullException("targetProfiles");

            ModeDescription closestDescription;
            SharpDX.Direct3D11.Device deviceTemp = null;
            try
            {
                var features = new SharpDX.Direct3D.FeatureLevel[targetProfiles.Length];
                for (int i = 0; i < targetProfiles.Length; i++)
                {
                    features[i] = (FeatureLevel)targetProfiles[i];
                }

                deviceTemp = new SharpDX.Direct3D11.Device(adapter.NativeAdapter, SharpDX.Direct3D11.DeviceCreationFlags.None, features);
            }
            catch (Exception) { }

            var description = new SharpDX.DXGI.ModeDescription()
            {
                Width = mode.Width,
                Height = mode.Height,
                RefreshRate = mode.RefreshRate.ToSharpDX(),
                Format = (SharpDX.DXGI.Format)mode.Format,
                Scaling = DisplayModeScaling.Unspecified,
                ScanlineOrdering = DisplayModeScanlineOrder.Unspecified
            };
            using (var device = deviceTemp)
                output.GetClosestMatchingMode(device, description, out closestDescription);

            return DisplayMode.FromDescription(closestDescription);
        }
Esempio n. 36
0
        public Framework(string title, int width, int height, bool depth, bool stencil, bool _VSync)
        {
            // Create the display to display on
            Window = new Form()
            {
                StartPosition = FormStartPosition.CenterScreen,
                ClientSize = new Size(width, height),
                Text = title,
                TopMost = true,
            };
            Window.StartPosition = FormStartPosition.Manual;
            Window.Location = new Point(1100, 80);
            Window.FormBorderStyle = FormBorderStyle.Fixed3D;
            Window.WindowState =FormWindowState.Normal;
            Window.CreateControl();
            VerticalSyncEnabled = _VSync;
            CreateDevice();

            // Create a description of the display mode
            var modeDescription = new ModeDescription()
            {
                Format = Format.R8G8B8A8_UNorm,
                RefreshRate = new Rational(60, 1),
                Scaling = DisplayModeScaling.Unspecified,
                ScanlineOrdering = DisplayModeScanlineOrder.Unspecified,
                Width = width,
                Height = height,
            };

            // Create a description of the sampling for multisampling or antialiasing
            var sampleDescription = new SampleDescription()
            {
                Count = 1,
                Quality = 0,
            };

            // Create a description of the swap chain or front and back buffers
            var swapDescription = new SwapChainDescription()
            {
                ModeDescription = modeDescription,
                SampleDescription = sampleDescription,
                BufferCount = 1,
                Flags = SwapChainFlags.None,
                IsWindowed = true,
                OutputHandle = Window.Handle,
                SwapEffect = SwapEffect.Discard,
                Usage = Usage.RenderTargetOutput,
            };

            // Create the DirectX 11 Device
            SharpDX.Direct3D11.Device.CreateWithSwapChain(SharpDX.Direct3D.DriverType.Hardware, DeviceCreationFlags.BgraSupport|DeviceCreationFlags.Debug, swapDescription, out Device, out swapChain);

            DContext = Device.ImmediateContext;
            // Create the factory which manages general graphics resources
            // Ignore all windows events
            Factory = swapChain.GetParent<Factory>();
            Factory.MakeWindowAssociation(Window.Handle, WindowAssociationFlags.IgnoreAll);
            Factory.Dispose();
            // New RenderTargetView from the backbuffer
            var backBuffer = Texture2D.FromSwapChain<Texture2D>(swapChain, 0);
            RenderTargetView = new RenderTargetView(Device, backBuffer);
            RenderTargetView.DebugName = "std";
            // Release pointer to the back buffer as we no longer need it.
            backBuffer.Dispose();

            frame_width=Window.ClientSize.Width;
            frame_height=Window.ClientSize.Height;

            #region Zdepth
            if (depth || stencil)
            {
                _depth=true;
                var textureDescription = new Texture2DDescription()
                {
                    Width = frame_width,
                    Height = frame_height,
                    MipLevels = 1,
                    ArraySize = 1,
                    Format = (stencil) ? Format.D32_Float : Format.D24_UNorm_S8_UInt,
                    SampleDescription = sampleDescription,
                    Usage = ResourceUsage.Default,
                    BindFlags = BindFlags.DepthStencil,
                    CpuAccessFlags = CpuAccessFlags.None,
                    OptionFlags = ResourceOptionFlags.None,
                };

                var texture = new Texture2D(Device, textureDescription);

                var depthStencilViewDescription = new DepthStencilViewDescription()
                {
                    Format = textureDescription.Format,
                    Dimension = DepthStencilViewDimension.Texture2DMultisampled
                };

                DepthStencilView = new DepthStencilView(Device, texture, depthStencilViewDescription);
                DContext.OutputMerger.SetTargets(DepthStencilView, RenderTargetView);
            }
            else
            {
                DContext.OutputMerger.SetTargets(RenderTargetView);
            }

            if (depth && !stencil)
                depthStencilClear = DepthStencilClearFlags.Depth;
            else if (stencil && !depth)
                depthStencilClear = DepthStencilClearFlags.Stencil;
            else if (stencil && depth)
                depthStencilClear = DepthStencilClearFlags.Stencil | DepthStencilClearFlags.Depth;
            #endregion

            #region Rasterizer
            RasterizerStateDescription RAS = new RasterizerStateDescription();
            RAS.IsMultisampleEnabled = true; //important for AA
            RAS.CullMode = CullMode.Back;
            RAS.DepthBias = 0;
            RAS.DepthBiasClamp = 0.0f;
            RAS.FillMode = FillMode.Solid;
            RAS.IsDepthClipEnabled = false;
            RAS.IsFrontCounterClockwise = true;
            DContext.Rasterizer.State = new RasterizerState(Device, RAS);
            #endregion

            // Setup the camera viewport
            var viewport = new Viewport()
            {
                TopLeftX = 0,
                TopLeftY = 0,
                Width = width,
                Height = height,
                MinDepth = 0.0f,
                MaxDepth = 1.0f,
            };
            DContext.Rasterizer.SetViewports(viewport);

            Stopwatch = new Stopwatch();
        }
Esempio n. 37
0
        /// <summary>
        ///     Hooked to allow resizing a texture/surface that is reused. Currently not in use as we create the texture for each
        ///     request
        ///     to support different sizes each time (as we use DirectX to copy only the region we are after rather than the entire
        ///     backbuffer)
        /// </summary>
        /// <param name="swapChainPtr"></param>
        /// <param name="newTargetParameters"></param>
        /// <returns></returns>
        private int ResizeTargetHook(IntPtr swapChainPtr, ref ModeDescription newTargetParameters)
        {
            // Dispose of overlay engine (so it will be recreated with correct renderTarget view size)
            if (_overlayEngine != null)
            {
                _overlayEngine.Dispose();
                _overlayEngine = null;
            }

            return DXGISwapChain_ResizeTargetHook.Original(swapChainPtr, ref newTargetParameters);
        }
Esempio n. 38
0
 internal static DisplayMode FromDescription(ModeDescription description)
 {
     return new DisplayMode((PixelFormat)description.Format, description.Width, description.Height, new Rational(description.RefreshRate.Numerator, description.RefreshRate.Denominator));
 }
Esempio n. 39
0
        protected void InitializeDirectXResources()
        {
            ScaleFactor = (float)GraphicsUtils.Scale;

            var clientSize     = ClientSize;
            var backBufferDesc = new DXGI.ModeDescription(clientSize.Width, clientSize.Height,
                                                          new DXGI.Rational(60, 1), DXGI.Format.R8G8B8A8_UNorm);

            var swapChainDesc = new DXGI.SwapChainDescription()
            {
                ModeDescription   = backBufferDesc,
                SampleDescription = new DXGI.SampleDescription(1, 0),
                Usage             = DXGI.Usage.RenderTargetOutput,
                BufferCount       = 1,
                OutputHandle      = Handle,
                SwapEffect        = DXGI.SwapEffect.Discard,
                IsWindowed        = Paradigm.Config.Test.Debug
            };

            D3D11.Device.CreateWithSwapChain(D3D.DriverType.Hardware, D3D11.DeviceCreationFlags.BgraSupport,
                                             new[] { D3D.FeatureLevel.Level_10_0 }, swapChainDesc, out D3DDevice, out var swapChain);
            D3DDeviceContext = D3DDevice.ImmediateContext;

            SwapChain = new DXGI.SwapChain1(swapChain.NativePointer);

            D2DFactory = new D2D1.Factory();

            using (var backBuffer = SwapChain.GetBackBuffer <D3D11.Texture2D>(0))
            {
                RenderTargetView = new D3D11.RenderTargetView(D3DDevice, backBuffer);
                RenderTarget     = new D2D1.RenderTarget(D2DFactory, backBuffer.QueryInterface <DXGI.Surface>(),
                                                         new D2D1.RenderTargetProperties(new D2D1.PixelFormat(DXGI.Format.Unknown, D2D1.AlphaMode.Premultiplied)))
                {
                    TextAntialiasMode = D2D1.TextAntialiasMode.Cleartype
                };
            }

            DwFactory = new DW.Factory(DW.FactoryType.Shared);

            _customColorRenderer.AssignResources(RenderTarget, ForegroundBrush);

            CueTextFormat = new DW.TextFormat(DwFactory, "Arial", DW.FontWeight.Bold,
                                              DW.FontStyle.Normal, DW.FontStretch.Normal, 120 * ScaleFactor)
            {
                TextAlignment      = DW.TextAlignment.Center,
                ParagraphAlignment = DW.ParagraphAlignment.Center
            };
            SubtitleTextFormat = new DW.TextFormat(DwFactory, "Consolas", DW.FontWeight.Light,
                                                   DW.FontStyle.Normal, DW.FontStretch.Normal, Paradigm.Config.Gui.InputTextFontSize * ScaleFactor / 2)
            {
                TextAlignment      = DW.TextAlignment.Center,
                ParagraphAlignment = DW.ParagraphAlignment.Center
            };
            ButtonLabelTextFormat = new DW.TextFormat(DwFactory, "Consolas", DW.FontWeight.Bold,
                                                      DW.FontStyle.Normal, DW.FontStretch.Normal, Paradigm.Config.Gui.ButtonFontSize * ScaleFactor)
            {
                TextAlignment      = DW.TextAlignment.Center,
                ParagraphAlignment = DW.ParagraphAlignment.Center
            };
            InputTextFormat = new DW.TextFormat(DwFactory, "Consolas", DW.FontWeight.Bold,
                                                DW.FontStyle.Normal, DW.FontStretch.Normal, Paradigm.Config.Gui.InputTextFontSize * ScaleFactor)
            {
                TextAlignment      = DW.TextAlignment.Leading,
                ParagraphAlignment = DW.ParagraphAlignment.Center
            };

            SharedBrush       = new D2D1.SolidColorBrush(RenderTarget, Color.White);
            BackgroundBrush   = new D2D1.SolidColorBrush(RenderTarget, BackgroundColor);
            ForegroundBrush   = new D2D1.SolidColorBrush(RenderTarget, ForegroundColor);
            CorrectColorBrush = new D2D1.SolidColorBrush(RenderTarget, CorrectTextColor);
            WrongColorBrush   = new D2D1.SolidColorBrush(RenderTarget, WrongTextColor);

            PostInitDirectXResources();
        }
Esempio n. 40
0
 public static DisplayMode FromDescription(ModeDescription description)
 {
     return new DisplayMode(description.Format, description.Width, description.Height, description.RefreshRate);
 }