Exemplo n.º 1
0
        public static IComObject <T> CreateSwapChainForComposition <T>(this IDXGIFactory2 factory,
                                                                       IDXGIDevice1 device,
                                                                       DXGI_SWAP_CHAIN_DESC1 desc,
                                                                       IDXGIOutput1 restrictToOutput = null) where T : IDXGISwapChain1
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            factory.CreateSwapChainForComposition(device, ref desc, restrictToOutput, out var swapChain).ThrowOnError();
            return(new ComObject <T>((T)swapChain));
        }
Exemplo n.º 2
0
        public static ComObject <T> CreateSwapChainForHwnd <T>(this IDXGIFactory2 factory,
                                                               IDXGIDevice1 device,
                                                               IntPtr hwnd,
                                                               DXGI_SWAP_CHAIN_DESC1 desc,
                                                               DXGI_SWAP_CHAIN_FULLSCREEN_DESC?fullScreenDesc = null,
                                                               IDXGIOutput1 restrictToOutput = null) where T : IDXGISwapChain1
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            using (var mem = fullScreenDesc.StructureToMemory())
            {
                factory.CreateSwapChainForHwnd(device, hwnd, ref desc, mem.Pointer, restrictToOutput, out var swapChain).ThrowOnError();
                return(new ComObject <T>((T)swapChain));
            }
        }
Exemplo n.º 3
0
 public static ComObject <T> CreateSwapChainForHwnd <T>(this ComObject <IDXGIFactory2> factory,
                                                        ComObject <IDXGIDevice1> device,
                                                        IntPtr hwnd,
                                                        DXGI_SWAP_CHAIN_DESC1 desc,
                                                        DXGI_SWAP_CHAIN_FULLSCREEN_DESC?fullScreenDesc = null,
                                                        ComObject <IDXGIOutput1> restrictToOutput      = null) where T : IDXGISwapChain1 => CreateSwapChainForHwnd <T>(factory?.Object, device?.Object, hwnd, desc, fullScreenDesc, restrictToOutput?.Object);
Exemplo n.º 4
0
 public static IComObject <T> CreateSwapChainForComposition <T>(this IComObject <IDXGIFactory2> factory,
                                                                IComObject <IDXGIDevice1> device,
                                                                DXGI_SWAP_CHAIN_DESC1 desc,
                                                                IComObject <IDXGIOutput1> restrictToOutput = null) where T : IDXGISwapChain1 => CreateSwapChainForComposition <T>(factory?.Object, device?.Object, desc, restrictToOutput?.Object);