Пример #1
0
        public DxgiSwapChain3 CreateSwapChainForWindowHandle(
            object device,
            IntPtr hwnd,
            DxgiSwapChainDesc1 desc,
            DxgiSwapChainFullscreenDesc?fullscreenDesc,
            DxgiOutput3 restrictToOutput)
        {
            if (fullscreenDesc == null)
            {
                return(new DxgiSwapChain3((IDxgiSwapChain2)this.factory.CreateSwapChainForWindowHandle(
                                              device,
                                              hwnd,
                                              ref desc,
                                              IntPtr.Zero,
                                              restrictToOutput == null ? null : restrictToOutput.GetHandle <IDxgiOutput>())));
            }
            else
            {
                IntPtr fullscreenDescPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DxgiSwapChainFullscreenDesc)));

                try
                {
                    Marshal.StructureToPtr(fullscreenDesc.Value, fullscreenDescPtr, false);
                    return(new DxgiSwapChain3((IDxgiSwapChain2)this.factory.CreateSwapChainForWindowHandle(
                                                  device,
                                                  hwnd,
                                                  ref desc,
                                                  fullscreenDescPtr,
                                                  restrictToOutput == null ? null : restrictToOutput.GetHandle <IDxgiOutput>())));
                }
                finally
                {
                    Marshal.FreeHGlobal(fullscreenDescPtr);
                }
            }
        }
        public DxgiSwapChain3 CreateSwapChainForWindowHandle(
            object device,
            IntPtr hwnd,
            DxgiSwapChainDesc1 desc,
            DxgiSwapChainFullscreenDesc? fullscreenDesc,
            DxgiOutput3 restrictToOutput)
        {
            if (fullscreenDesc == null)
            {
                return new DxgiSwapChain3((IDxgiSwapChain2)this.factory.CreateSwapChainForWindowHandle(
                    device,
                    hwnd,
                    ref desc,
                    IntPtr.Zero,
                    restrictToOutput == null ? null : restrictToOutput.GetHandle<IDxgiOutput>()));
            }
            else
            {
                IntPtr fullscreenDescPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DxgiSwapChainFullscreenDesc)));

                try
                {
                    Marshal.StructureToPtr(fullscreenDesc.Value, fullscreenDescPtr, false);
                    return new DxgiSwapChain3((IDxgiSwapChain2)this.factory.CreateSwapChainForWindowHandle(
                        device,
                        hwnd,
                        ref desc,
                        fullscreenDescPtr,
                        restrictToOutput == null ? null : restrictToOutput.GetHandle<IDxgiOutput>()));
                }
                finally
                {
                    Marshal.FreeHGlobal(fullscreenDescPtr);
                }
            }
        }