private static IDXGISwapChain3 CreateSwapChain(GraphicsDevice device, PresentationParameters presentationParameters, IntPtr windowHandle)
        {
            SwapChainDescription1 swapChainDescription = new SwapChainDescription1
            {
                Width             = presentationParameters.BackBufferWidth,
                Height            = presentationParameters.BackBufferHeight,
                SampleDescription = new SampleDescription(1, 0),
                Stereo            = presentationParameters.Stereo,
                Usage             = Usage.RenderTargetOutput,
                BufferCount       = BufferCount,
                Scaling           = Scaling.Stretch,
                SwapEffect        = SwapEffect.FlipSequential,
                Format            = (Format)presentationParameters.BackBufferFormat,
                Flags             = SwapChainFlags.None,
                AlphaMode         = AlphaMode.Unspecified
            };

            DXGI.CreateDXGIFactory2(false, out IDXGIFactory2 factory);
            using IDXGISwapChain1 tempSwapChain = factory.CreateSwapChainForHwnd(device.NativeDirectCommandQueue, windowHandle, swapChainDescription);
            factory.Dispose();

            return(tempSwapChain.QueryInterface <IDXGISwapChain3>());
        }
Beispiel #2
0
        private static IDXGISwapChain3 CreateSwapChain(GraphicsDevice device, PresentationParameters presentationParameters, SwapChainPanel swapChainPanel)
        {
            SwapChainDescription1 swapChainDescription = new SwapChainDescription1
            {
                Width             = presentationParameters.BackBufferWidth,
                Height            = presentationParameters.BackBufferHeight,
                SampleDescription = new Vortice.DXGI.SampleDescription(1, 0),
                Stereo            = presentationParameters.Stereo,
                Usage             = Usage.RenderTargetOutput,
                BufferCount       = BufferCount,
                Scaling           = Scaling.Stretch,
                SwapEffect        = SwapEffect.FlipSequential,
                Format            = (Format)presentationParameters.BackBufferFormat.ToNonSRgb(),
                Flags             = SwapChainFlags.None,
                AlphaMode         = AlphaMode.Unspecified
            };

            swapChainDescription.AlphaMode = AlphaMode.Premultiplied;

            DXGI.CreateDXGIFactory2(false, out IDXGIFactory2 factory);
            Direct3DInterop.ISwapChainPanelNative nativePanel = (Direct3DInterop.ISwapChainPanelNative)swapChainPanel;
            using IDXGISwapChain1 tempSwapChain = factory.CreateSwapChainForComposition(device.DirectCommandQueue.NativeCommandQueue, swapChainDescription);
            factory.Dispose();

            IDXGISwapChain3 swapChain = tempSwapChain.QueryInterface <IDXGISwapChain3>();

            nativePanel.SetSwapChain(swapChain.NativePointer);

            swapChain.MatrixTransform = new Matrix3x2
            {
                M11 = 1.0f / swapChainPanel.CompositionScaleX,
                M22 = 1.0f / swapChainPanel.CompositionScaleY
            };

            return(swapChain);
        }
 public CoreWindowSwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters, CoreWindow coreWindow)
     : base(device, presentationParameters, CreateSwapChain(device, presentationParameters, coreWindow))
 {
     this.coreWindow = coreWindow;
 }
Beispiel #4
0
 public XamlSwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters, SwapChainPanel swapChainPanel)
     : base(device, presentationParameters, CreateSwapChain(device, presentationParameters, swapChainPanel))
 {
     this.swapChainPanel = swapChainPanel;
 }
 public HwndSwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters, IntPtr windowHandle)
     : base(device, presentationParameters, CreateSwapChain(device, presentationParameters, windowHandle))
 {
     this.windowHandle = windowHandle;
 }