예제 #1
0
        private void CreateDeviceAndSwapChain()
        {
            nativeDevice = new NativeDevice();

            backBuffer = new BackBuffer(nativeDevice.GetFactory2(), nativeDevice.D3D11Device, renderForm);

            renderTargetView = new RenderTargetView(nativeDevice.D3D11Device, backBuffer.BackBufferTexture);

            ViewPort = new Viewport(0, 0, renderForm.Width, renderForm.Height, 0, 1);
        }
        public LeaDepthStencilState(NativeDevice nativeDevice, bool isDepthTestingEnable)
        {
            var depthStencilStateDesc = new DepthStencilStateDescription
            {
                IsDepthEnabled   = isDepthTestingEnable,
                DepthWriteMask   = DepthWriteMask.All,
                DepthComparison  = Comparison.Less,
                IsStencilEnabled = false,
                StencilWriteMask = 0xff,
                StencilReadMask  = 0xff
            };


            depthStencilState = new DepthStencilState(nativeDevice.D3D11Device, depthStencilStateDesc);
        }
예제 #3
0
        public DepthBuffer(NativeDevice nativeDevice, int width, int height)
        {
            depthBufferTexture = new Texture2D(nativeDevice.D3D11Device, new Texture2DDescription()
            {
                Format            = Format.D32_Float_S8X24_UInt,
                ArraySize         = 1,
                MipLevels         = 1,
                Width             = width,
                Height            = height,
                SampleDescription = new SampleDescription(4, 0),
                Usage             = ResourceUsage.Default,
                BindFlags         = BindFlags.DepthStencil,
                CpuAccessFlags    = CpuAccessFlags.None,
                OptionFlags       = ResourceOptionFlags.None
            });


            depthStencilView = new DepthStencilView(nativeDevice.D3D11Device, depthBufferTexture);
        }