Esempio n. 1
0
        public void Draw()
        {
            Device.Reset();

            VertexBuffer.Update <Vertex>(Mesh.Vertices);

            IndexBuffer.Update <int>(Mesh.Indices);

            CommandList.ClearDepthStencilView(Texture, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil);

            CommandList.SetRenderTargets(Texture);

            //Clear our backbuffer to the updated color
            CommandList.Clear(Texture, new Color4(0.0f, 0.2f, 0.4f, 1));

            CommandList.SetInputLayout(Shaders.Layout);

            CommandList.SetViewPort(SwapChain.PresentParameters.Width, SwapChain.PresentParameters.Height, 0, 0);

            CommandList.SetVertexBuffer(VertexBuffer);

            CommandList.SetIndexBuffer(IndexBuffer);

            CommandList.SetVertexShader(Shaders.VertexShader);

            CommandList.SetPixelShader(Shaders.PixelShader);



            //---Draw Mesh
            CommandList.SetPrimitiveType(SharpDX.Direct3D.PrimitiveTopology.TriangleList);
            CommandList.DrawIndexed(Mesh.IndexCount);
        }
Esempio n. 2
0
        public void Draw()
        {
            Device.Reset();


            CommandList.ClearDepthStencilView(Texture, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil);

            CommandList.SetRenderTargets(Texture);

            //Clear our backbuffer to the updated color
            CommandList.Clear(Texture, new Color4(0.2f, 0.4f, 0.8f, 1.0f));

            CommandList.SetInputLayout(Shaders.Layout);

            CommandList.SetViewPort(SwapChain.PresentParameters.Width, SwapChain.PresentParameters.Height, 0, 0);

            CommandList.SetVertexShader(Shaders.VertexShader);

            CommandList.SetPixelShader(Shaders.PixelShader);



            for (int i = 0; i < RMesh.Worlds.Count(); i++)
            {
                RMesh.VertexBuffer.Update <Vertex>(Mesh.Vertices.Data.ToArray());
                RMesh.IndexBuffer.Update <int>(Mesh.Indices.Data.ToArray());
                RMesh.ConstantBuffer[0].UpdateConstant <Transform>(ShaderType.VertexShader, 0, new Transform(RMesh.Worlds[i], Camera.View, Camera.Proj)); // cbuffer MatrixBuffer (W V P) : register(b0)
                RMesh.ConstantBuffer[1].UpdateConstant <LightBuffer>(ShaderType.PixelShader, 0, RMesh.Light);
                RMesh.ConstantBuffer[2].UpdateConstant <CameraBuffer>(ShaderType.VertexShader, 1, new CameraBuffer(Camera.Position));
                CommandList.SetVertexBuffer(RMesh.VertexBuffer);
                CommandList.SetIndexBuffer(RMesh.IndexBuffer);
                CommandList.SetPrimitiveType(SharpDX.Direct3D.PrimitiveTopology.TriangleList);
                CommandList.SetRasterizerState(StateSolid);
                CommandList.SetSampler(ShaderType.PixelShader, SamplerState, 0);
                CommandList.SetShaderResource(ShaderType.PixelShader, RMesh.Texture, 0);
                CommandList.DrawIndexed(Mesh.Indices.Count);
            }



            RGrid.VertexBuffer.Update <Vertex>(Grid.Vertices.Data.ToArray());
            RGrid.IndexBuffer.Update <int>(Grid.Indices.Data.ToArray());
            RGrid.ConstantBuffer[0].UpdateConstant <Transform>(ShaderType.VertexShader, 0, new Transform(RGrid.Worlds[0], Camera.View, Camera.Proj)); // cbuffer MatrixBuffer (W V P) : register(b0)
            RGrid.ConstantBuffer[1].UpdateConstant <LightBuffer>(ShaderType.PixelShader, 0, RGrid.Light);
            RGrid.ConstantBuffer[2].UpdateConstant <CameraBuffer>(ShaderType.VertexShader, 1, new CameraBuffer(Camera.Position));
            CommandList.SetVertexBuffer(RGrid.VertexBuffer);
            CommandList.SetIndexBuffer(RGrid.IndexBuffer);
            CommandList.SetPrimitiveType(SharpDX.Direct3D.PrimitiveTopology.TriangleList);
            CommandList.SetRasterizerState(StateSolid);
            CommandList.SetSampler(ShaderType.PixelShader, SamplerState, 0);
            CommandList.SetShaderResource(ShaderType.PixelShader, RGrid.Texture, 0);
            CommandList.DrawIndexed(Grid.Indices.Count);
        }
Esempio n. 3
0
        public void Draw()
        {
            Device.Reset();

            VertexBuffer[0].Update <Vertex>(Grid.Vertices.ToArray());
            IndexBuffer[0].Update <int>(Grid.Indices.ToArray());

            VertexBuffer[1].Update <Vertex>(Mesh.Vertices.ToArray());
            IndexBuffer[1].Update <int>(Mesh.Indices.ToArray());

            CommandList.ClearDepthStencilView(Texture, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil);

            CommandList.SetRenderTargets(Texture);

            //Clear our backbuffer to the updated color
            CommandList.Clear(Texture, new Color4(0.0f, 0.2f, 0.4f, 1));

            CommandList.SetInputLayout(Shaders.Layout);

            CommandList.SetViewPort(SwapChain.PresentParameters.Width, SwapChain.PresentParameters.Height, 0, 0);

            CommandList.SetVertexShader(Shaders.VertexShader);

            CommandList.SetPixelShader(Shaders.PixelShader);


            //---Draw Grid #2
            CommandList.SetVertexBuffer(VertexBuffer[0]);
            CommandList.SetIndexBuffer(IndexBuffer[0]);
            ConstantBuffer.UpdateConstant <Transform>(ShaderType.VertexShader, 0, new Transform(World[0], Camera.View, Camera.Projection)); // cbuffer MatrixBuffer (W V P) : register(b0)
            CommandList.SetPrimitiveType(SharpDX.Direct3D.PrimitiveTopology.TriangleList);
            CommandList.SetRasterizerState(StateSolid);
            CommandList.SetSampler(ShaderType.PixelShader, SamplerState, 0);
            CommandList.SetShaderResource(ShaderType.PixelShader, Textures[0], 0);
            CommandList.DrawIndexed(Grid.IndexCount);



            //---Draw Grid #2
            CommandList.SetVertexBuffer(VertexBuffer[1]);
            CommandList.SetIndexBuffer(IndexBuffer[1]);
            ConstantBuffer.UpdateConstant <Transform>(ShaderType.VertexShader, 0, new Transform(World[1], Camera.View, Camera.Projection)); // cbuffer MatrixBuffer (W V P) : register(b0)
            CommandList.SetPrimitiveType(SharpDX.Direct3D.PrimitiveTopology.TriangleList);
            CommandList.SetRasterizerState(StateWireframe);
            CommandList.SetSampler(ShaderType.PixelShader, SamplerState, 0);
            CommandList.SetShaderResource(ShaderType.PixelShader, Textures[1], 0);
            CommandList.DrawIndexed(Mesh.IndexCount);
        }
Esempio n. 4
0
 public void Draw()
 {
     //Clear our backbuffer to the updated color
     CommandList.Clear(Texture, new Color4(0.0f, 0.2f, 0.4f, 1));
 }