Esempio n. 1
0
        public GL46SwapChain(SwapChainInfo swapChainInfo)
        {
            var options = new ToolkitOptions();

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

            _windowInfo = Utilities.CreateWindowsWindowInfo(swapChainInfo.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 = swapChainInfo.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);
        }
Esempio n. 2
0
        public DX12SwapChain(DX12GraphicsDevice graphicsDevice, SwapChainInfo swapChainInfo)
        {
            _factory = new DXGIFactory();

            var swapChainDescription = new SwapChainDescription
            {
                SwapEffect        = swapChainInfo.SwapEffect.ToSharpDX(),
                BufferCount       = 2,
                Flags             = SwapChainFlags.None,
                IsWindowed        = swapChainInfo.IsWindowed,
                ModeDescription   = new ModeDescription(swapChainInfo.Width, swapChainInfo.Height, new Rational(60, 1), Format.R8G8B8A8UNorm.ToSharpDX()),
                OutputHandle      = swapChainInfo.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);
        }
Esempio n. 3
0
        public D3D11SwapChain(D3D11GraphicsDevice graphiceDevice, SwapChainInfo swapChainInfo)
        {
            _swapChainInfo = swapChainInfo;
            _factory       = new DXGIFactory();

            var swapChainDescription = new SwapChainDescription
            {
                SwapEffect        = swapChainInfo.SwapEffect.ToSharpDX(),
                BufferCount       = 2,
                Flags             = SwapChainFlags.None,
                IsWindowed        = swapChainInfo.IsWindowed,
                ModeDescription   = new ModeDescription(swapChainInfo.Width, swapChainInfo.Height, new Rational(60, 1), Format.R8G8B8A8UNorm.ToSharpDX()),
                OutputHandle      = swapChainInfo.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, swapChainInfo.Width, swapChainInfo.Height, 0, false, 1, TextureViewType.RenderTarget);
            DepthStencilView = CreateDepthStencilView(graphiceDevice, swapChainInfo.Width, swapChainInfo.Height);
        }
Esempio n. 4
0
        public GL33SwapChain(SwapChainInfo swapChainInfo)
        {
            var windowInfo = Utilities.CreateWindowsWindowInfo(swapChainInfo.WindowHandle);

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