
CHAPTER 5 ■ GETTING THE MOST OUT OF VERTICES
471
vertices[i++] = new MyVertexPositionColor(new Vector3(1, 1, -1), Color.Red);
vertices[i++] = new MyVertexPositionColor(new Vector3(3, 5, -1), Color.Green);
vertices[i++] = new MyVertexPositionColor(new Vector3(5, 1, -1), Color.Blue);
vertBuffer = new VertexBuffer(device,
➥
MyVertexPositionColor.SizeInBytes * vertices.Length, ➥
BufferUsage.WriteOnly);
vertBuffer.SetData<MyVertexPositionColor>(vertices, 0, vertices.Length);
}
The first line creates the VertexDeclaration, which is nothing more than what you coded
in step 3 earlier. It will be passed to your graphics card before rendering the triangle. ...