private void DrawTriangleBuffer() { if (polygonCount * 3 > vertices.Length) { ResizeBuffers(); } int vertexIndex = 0; for (int i = 0; i < polygonCount; i++) { Triangle polygon = triangleBuffer[i]; var color = new Microsoft.Xna.Framework.Color( polygon.Color.R, polygon.Color.G, polygon.Color.B); vertices[vertexIndex + 0] = new VertexPositionColor( new Microsoft.Xna.Framework.Vector3(polygon.A.X, polygon.A.Y, polygon.A.Z), color); vertices[vertexIndex + 1] = new VertexPositionColor( new Microsoft.Xna.Framework.Vector3(polygon.B.X, polygon.B.Y, polygon.B.Z), color); vertices[vertexIndex + 2] = new VertexPositionColor( new Microsoft.Xna.Framework.Vector3(polygon.C.X, polygon.C.Y, polygon.C.Z), color); vertexIndex += 3; } vertexBuffer.SetData(vertices); device.SetVertexBuffer(vertexBuffer); foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) { pass.Apply(); if (polygonCount > 0) { device.DrawPrimitives(PrimitiveType.TriangleList, 0, polygonCount); } } device.SetVertexBuffer(null); device.Present(); }
public override void Draw(PrimitiveType primType, int vertexCount, int startVertex) { _device.DrawPrimitives(XNAHelper.ToXNAPrimitiveType(primType), startVertex, XNAHelper.GetPrimitiveCount(primType, vertexCount, false, 0)); }
public void Render(GraphicsDevice device) { //device.RenderState.FillMode = FillMode.WireFrame; if (draw_mode == DrawMode.Indexed) device.DrawIndexedPrimitives(primitive_type, 0, 0, vertices_count, 0, primitive_count); else device.DrawPrimitives(primitive_type, 0, primitive_count); }