Пример #1
0
        protected void TriangleContext(Pointdata a, Pointdata b, Pointdata c)
        {
            //clear history
            if (Vertices != null)
            {
                Vertices.Dispose();
                Layout.Dispose();
                Vertexbuffer.Dispose();
            }
            Vertices = new DataStream(12 * 3, true, true);
            Vertices.Write(new Vector3(a.x, a.y, a.z));
            Vertices.Write(new Vector3(b.x, b.y, b.z));
            Vertices.Write(new Vector3(c.x, c.y, c.z));
            Vertices.Position = 0;
            // create the vertex layout and buffer
            var elements = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0) };

            Layout       = new InputLayout(_device, InputSignature, elements);
            Vertexbuffer = new Buffer(_device, Vertices, 12 * 3, ResourceUsage.Default, BindFlags.VertexBuffer,
                                      CpuAccessFlags.None, ResourceOptionFlags.None, 0);

            // configure the Input Assembler portion of the pipeline with the vertex data
            Devicecontext.InputAssembler.InputLayout       = Layout;
            Devicecontext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
            Devicecontext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(Vertexbuffer, 12, 0));

            // set the shaders
            Devicecontext.VertexShader.Set(Vertexshader);
            Devicecontext.PixelShader.Set(Pixelshader);
            // draw the triangle
            Devicecontext.Draw(3, 0);
        }
Пример #2
0
 public void Cleancanvas()
 {
     // clear the render target to a soothing white
     Devicecontext.ClearRenderTargetView(Rendertarget, color4);
 }