Rendering Meshes Using the Programmable Pipeline

The simple triangle example is just that: simple. It's rare that you would use a vertex program on a single triangle in a real-world example, so instead of using this example, you should switch to rendering an entire mesh. Go ahead and replace the variables for the vertex declaration and the vertex buffer with this one for the mesh:

private Mesh mesh = null;

One nice thing about the mesh objects is that when they are rendered, they will automatically set the vertex declaration, so you don't need to worry about it. Naturally, you'll need to remove all instances in the code that dealt with either the vertex buffer or vertex declaration, as well. You will also need to update the initialize method ...

Get Managed DirectX® 9 Kick Start: Graphics and Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.