Exemple #1
0
        public SwapchainD3D12(
            D3D12GraphicsDevice device,
            SwapChainDescriptor descriptor,
            int backbufferCount)
            : base(device, descriptor, device.DXGIFactory, device.GraphicsQueue, backbufferCount, backbufferCount)
        {
            _backbufferTextures = new TextureD3D12[backbufferCount];
            for (int i = 0; i < backbufferCount; i++)
            {
                var backBufferTexture = _swapChain.GetBuffer <ID3D12Resource>(i);
                var d3dTextureDesc    = backBufferTexture.Description;
                var textureDescriptor = TextureDescriptor.Texture2D(
                    (int)d3dTextureDesc.Width,
                    d3dTextureDesc.Height,
                    d3dTextureDesc.MipLevels,
                    d3dTextureDesc.DepthOrArraySize,
                    d3dTextureDesc.Format.FromDirectXPixelFormat(),
                    D3D12Convert.Convert(d3dTextureDesc.Flags),
                    (SampleCount)d3dTextureDesc.SampleDescription.Count);

                _backbufferTextures[i] = new TextureD3D12(device, textureDescriptor, backBufferTexture);
            }

            // Configure base.
            Configure(descriptor);
        }
Exemple #2
0
        public GL46SwapChain(SwapChainDescriptor swapChainDescriptor)
        {
            var options = new ToolkitOptions();

            options.Backend = PlatformBackend.Default;
            Toolkit.Init(options);

            _windowInfo = Utilities.CreateWindowsWindowInfo(swapChainDescriptor.WindowHandle);
            var graphicsContextFlags = GraphicsContextFlags.ForwardCompatible;

#if DEBUG
            graphicsContextFlags |= GraphicsContextFlags.Debug;
#endif
            _nativeContext = new GraphicsContext(GraphicsMode.Default, _windowInfo, null, 4, 6, graphicsContextFlags);
            _nativeContext.LoadAll();
            TurnOnDebugging();
            _nativeContext.MakeCurrent(_windowInfo);
            _nativeContext.SwapInterval = swapChainDescriptor.VSync ? 1 : 0;

            OpenTK.Graphics.OpenGL4.GL.Enable(EnableCap.CullFace);
            OpenTK.Graphics.OpenGL4.GL.CullFace(CullFaceMode.Back);
            OpenTK.Graphics.OpenGL4.GL.FrontFace(FrontFaceDirection.Ccw);

            OpenTK.Graphics.OpenGL4.GL.Enable(EnableCap.DepthTest);
            OpenTK.Graphics.OpenGL4.GL.DepthFunc(DepthFunction.Less);
        }
Exemple #3
0
        public DX12SwapChain(DX12GraphicsDevice graphicsDevice, SwapChainDescriptor swapChainDescriptor)
        {
            _factory = new DXGIFactory();

            var swapChainDescription = new SwapChainDescription
            {
                SwapEffect        = swapChainDescriptor.SwapEffect.ToSharpDX(),
                BufferCount       = 2,
                Flags             = SwapChainFlags.None,
                IsWindowed        = swapChainDescriptor.IsWindowed,
                ModeDescription   = new ModeDescription(swapChainDescriptor.Width, swapChainDescriptor.Height, new Rational(60, 1), Format.R8G8B8A8UNorm.ToSharpDX()),
                OutputHandle      = swapChainDescriptor.WindowHandle,
                SampleDescription = new SampleDescription(1, 0),
                Usage             = Usage.RenderTargetOutput
            };

            using var tempSwapChain = new SwapChain(_factory, graphicsDevice, swapChainDescription);
            _swapChain = tempSwapChain.QueryInterface <SwapChain3>();

            TextureView = new D3D12TextureView(graphicsDevice, 1, DescriptorHeapFlags.ShaderVisible, DescriptorHeapType.RenderTargetView);
        }
Exemple #4
0
        public D3D11SwapChain(D3D11GraphicsDevice graphiceDevice, SwapChainDescriptor swapChainDescriptor)
        {
            _swapChainDescriptor = swapChainDescriptor;
            _factory             = new DXGIFactory();

            var swapChainDescription = new SwapChainDescription
            {
                SwapEffect        = swapChainDescriptor.SwapEffect.ToSharpDX(),
                BufferCount       = 2,
                Flags             = SwapChainFlags.None,
                IsWindowed        = swapChainDescriptor.IsWindowed,
                ModeDescription   = new ModeDescription(swapChainDescriptor.Width, swapChainDescriptor.Height, new Rational(60, 1), Format.R8G8B8A8UNorm.ToSharpDX()),
                OutputHandle      = swapChainDescriptor.WindowHandle,
                SampleDescription = new SampleDescription(1, 0),
                Usage             = Usage.RenderTargetOutput
            };

            _swapChain         = new SwapChain(_factory, graphiceDevice, swapChainDescription);
            using var resource = _swapChain.GetBackBuffer <D3D11Texture2D>(0);

            TextureView      = new D3D11TextureView(graphiceDevice, resource, swapChainDescriptor.Width, swapChainDescriptor.Height, 0, false, 1, TextureViewType.RenderTarget);
            DepthStencilView = CreateDepthStencilView(graphiceDevice, swapChainDescriptor.Width, swapChainDescriptor.Height);
        }
Exemple #5
0
        public GL33SwapChain(SwapChainDescriptor swapChainDescriptor)
        {
            var windowInfo = Utilities.CreateWindowsWindowInfo(swapChainDescriptor.WindowHandle);

            _nativeContext = new GraphicsContext(GraphicsMode.Default, windowInfo, null, 3, 3, GraphicsContextFlags.Debug);
        }