示例#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();
        }
示例#2
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();
        }
示例#3
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();
        }
示例#4
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();
        }