Ejemplo n.º 1
0
        private void BeginScene()
        {
            // make sure buffers are initialized with current size
            EnsureOutputBuffers();

            // bind the views to the output merger stage
            _dxDevice.OutputMerger.SetTargets(_dxDepthStencilView, _dxRenderView);

            // clear buffers
            _dxDevice.ClearDepthStencilView(_dxDepthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0);
            _dxDevice.ClearRenderTargetView(_dxRenderView, new Color4(0f, 0, 0, 0)); // uses transparent color

            // set rasterization parameters
            var rsd = new RasterizerStateDescription
            {
                //IsAntialiasedLineEnabled = true,
                IsFrontCounterclockwise = false,
                CullMode = CullMode.None,
                FillMode = (_wireframe) ? FillMode.Wireframe : FillMode.Solid
            };

            RasterizerState rsdState = RasterizerState.FromDescription(_dxDevice, rsd);

            _dxDevice.Rasterizer.State = rsdState;

            // set viewport
            _dxDevice.Rasterizer.SetViewports(new Viewport(0, 0, ClientWidth, ClientHeight, 0.0f, 1.0f));
        }
Ejemplo n.º 2
0
        public void Render(int arg)
        {
            D3DDevice.OutputMerger.SetTargets(SampleDepthView, SampleRenderView);
            D3DDevice.Rasterizer.SetViewports(new Viewport(0, 0, WindowWidth, WindowHeight, 0.0f, 1.0f));

            D3DDevice.ClearDepthStencilView(SampleDepthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0);
            float c = ((float)(arg % 1000)) / 999.0f;

            D3DDevice.ClearRenderTargetView(SampleRenderView, new SlimDX.Color4(1.0f, c, c, c));

            D3DDevice.InputAssembler.SetInputLayout(SampleLayout);
            D3DDevice.InputAssembler.SetPrimitiveTopology(PrimitiveTopology.TriangleList);
            D3DDevice.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(SampleVertices, 32, 0));

            EffectTechnique technique = SampleEffect.GetTechniqueByIndex(0);
            EffectPass      pass      = technique.GetPassByIndex(0);

            for (int i = 0; i < technique.Description.PassCount; ++i)
            {
                pass.Apply();
                D3DDevice.Draw(3, 0);
            }

            D3DDevice.Flush();
        }