예제 #1
0
        public void VisualTestDepthBufferEnable(bool depthBufferEnable)
        {
            PrepareFrameCapture();

            var cube = new Simple3DCubeComponent(gd);

            cube.LoadContent();

            gd.DepthStencilState = new DepthStencilState
            {
                DepthBufferEnable = depthBufferEnable
            };

            gd.Clear(Color.CornflowerBlue);

            cube.CubeColor = Color.Red;
            cube.Draw();

            cube.CubePosition = new Vector3(0.4f, 0, 0);
            cube.CubeColor    = Color.Green;
            cube.Draw();

            CheckFrames();

            cube.UnloadContent();
        }
예제 #2
0
        public void VisualTestStencilBuffer()
        {
            PrepareFrameCapture();
            var cube = new Simple3DCubeComponent(gd);

            cube.LoadContent();

            gd.Clear(
                ClearOptions.DepthBuffer | ClearOptions.Stencil | ClearOptions.Target,
                Color.CornflowerBlue, 1, 0);

            var depthStencilState = new DepthStencilState
            {
                ReferenceStencil  = 1,
                StencilEnable     = true,
                StencilFunction   = CompareFunction.Always,
                StencilPass       = StencilOperation.Replace,
                DepthBufferEnable = false
            };

            gd.DepthStencilState = depthStencilState;

            cube.CubeColor = Color.Red;
            cube.Draw();

            depthStencilState.Dispose();
            depthStencilState = new DepthStencilState
            {
                ReferenceStencil  = 0,
                StencilEnable     = true,
                StencilFunction   = CompareFunction.Equal,
                StencilPass       = StencilOperation.Keep,
                DepthBufferEnable = false
            };
            gd.DepthStencilState = depthStencilState;

            cube.CubePosition = new Vector3(0.4f, 0, 0);
            cube.CubeColor    = Color.Green;
            cube.Draw();

            CheckFrames();

            depthStencilState.Dispose();
            cube.UnloadContent();
        }