コード例 #1
0
        private IDXGISwapChain3 CreateSwapChain(IDXGIFactory4 factory, ID3D12CommandQueue commandQueue, Format format)
        {
            SwapChainDescription1 desc = new SwapChainDescription1();

            desc.Format                  = format;
            desc.Width                   = Window.Width;
            desc.Height                  = Window.Height;
            desc.BufferCount             = DefaultSwapChainBuffers;
            desc.Usage                   = Usage.RenderTargetOutput;
            desc.SwapEffect              = SwapEffect.FlipDiscard;
            desc.SampleDescription       = new SampleDescription();
            desc.SampleDescription.Count = 1;

            var swapChain = factory.CreateSwapChainForHwnd(commandQueue, (IntPtr)Window.Handle, desc);

            return(swapChain.QueryInterface <IDXGISwapChain3>());
        }
コード例 #2
0
        public IDXGISwapChain3 CreateDXGISwapChain(IDXGIFactory4 pFactory, IntPtr hwnd, int width, int height, Vortice.DXGI.Format format, ID3D12CommandQueue pCommandQueue)
        {
            SwapChainDescription1 swapChainDesc = new SwapChainDescription1();

            swapChainDesc.BufferCount       = kDefaultSwapChainBuffers;
            swapChainDesc.Width             = width;
            swapChainDesc.Height            = height;
            swapChainDesc.Format            = format;
            swapChainDesc.Usage             = Usage.RenderTargetOutput;
            swapChainDesc.SwapEffect        = SwapEffect.FlipDiscard;
            swapChainDesc.SampleDescription = new SampleDescription(1, 0);

            // CreateSwapChainForHwnd() doesn't accept IDXGISwapChain3 (Why MS? Why?)
            IDXGISwapChain1 pSwapChain  = pFactory.CreateSwapChainForHwnd(pCommandQueue, hwnd, swapChainDesc);
            IDXGISwapChain3 pSwapChain3 = pSwapChain.QueryInterface <IDXGISwapChain3>();

            return(pSwapChain3);
        }