// Create a new VertexBuffer object var buffer = new VertexBuffer(GraphicsDevice, 3, BufferUsage.WriteOnly); // Define the vertices var vertices = new VertexPositionColor[] { new VertexPositionColor(new Vector3(0, 0, 0), Color.Red), new VertexPositionColor(new Vector3(1, 0, 0), Color.Green), new VertexPositionColor(new Vector3(0, 1, 0), Color.Blue) }; // Set the data of the buffer buffer.SetData(vertices);
// Create a new VertexBuffer object var buffer = new VertexBufferThis example creates a new VertexBuffer object and defines four vertices with positions and texture coordinates. The data of the buffer is then set to the array of vertices. The VertexBuffer class is part of the Microsoft.Xna.Framework.Graphics namespace, which is included in the Monogame package library.(GraphicsDevice, 4, BufferUsage.WriteOnly); // Define the vertices var vertices = new VertexPositionTexture[] { new VertexPositionTexture(new Vector3(-1, -1, 0), new Vector2(0, 1)), new VertexPositionTexture(new Vector3(-1, 1, 0), new Vector2(0, 0)), new VertexPositionTexture(new Vector3(1, 1, 0), new Vector2(1, 0)), new VertexPositionTexture(new Vector3(1, -1, 0), new Vector2(1, 1)), }; // Set the data of the buffer buffer.SetData(vertices);