Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 protected void Clean()
 {
     // clean up all resources
     // anything we missed will show up in the debug output
     Vertices.Close();
     Vertexbuffer.Dispose();
     Layout.Dispose();
     InputSignature.Dispose();
     Vertexshader.Dispose();
     Pixelshader.Dispose();
     Rendertarget.Dispose();
     _swapchain.Dispose();
     _device.Dispose();
 }