Beispiel #1
0
        public void VisualTestDepthBufferEnable(bool depthBufferEnable)
        {
            var cube = new Simple3DCubeComponent(Game);

            Game.PreInitializeWith += (sender, e) =>
            {
                cube.Initialize();
            };

            Game.DrawWith += (sender, e) =>
            {
                Game.GraphicsDevice.DepthStencilState = new DepthStencilState
                {
                    DepthBufferEnable = depthBufferEnable
                };

                Game.GraphicsDevice.Clear(Color.CornflowerBlue);

                cube.CubeColor = Color.Red;
                cube.Draw(e.FrameInfo.GameTime);

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

            RunSingleFrameTest();
        }
Beispiel #2
0
        public void VisualTestStencilBuffer()
        {
            var cube = new Simple3DCubeComponent(Game);

            Game.PreInitializeWith += (sender, e) =>
            {
                cube.Initialize();
            };

            Game.DrawWith += (sender, e) =>
            {
                Game.GraphicsDevice.Clear(
                    ClearOptions.DepthBuffer | ClearOptions.Stencil | ClearOptions.Target,
                    Color.CornflowerBlue, 1, 0);

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

                cube.CubeColor = Color.Red;
                cube.Draw(e.FrameInfo.GameTime);

                Game.GraphicsDevice.DepthStencilState = new DepthStencilState
                {
                    ReferenceStencil  = 0,
                    StencilEnable     = true,
                    StencilFunction   = CompareFunction.Equal,
                    StencilPass       = StencilOperation.Keep,
                    DepthBufferEnable = false
                };

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

            RunSingleFrameTest();
        }