Using Vertex Buffers

Direct3D has just the mechanism needed for this: vertex buffers. A vertex buffer, much like its name, is a memory store for vertices. The flexibility of vertex buffers makes them ideal for sharing transformed geometry in your scene. So how can the simple triangle application from Chapter 1, “Introducing Direct3D,” be modified to use vertex buffers?

Creating a vertex buffer is quite simple. There are three constructors that can be used to do so; we will look at each one.

public VertexBuffer ( Microsoft.DirectX.Direct3D.Device device , System.Int32
   sizeOfBufferInBytes , Microsoft.DirectX.Direct3D.Usage usage ,
   Microsoft.DirectX.Direct3D.VertexFormats vertexFormat ,
   Microsoft.DirectX.Direct3D.Pool pool ) public VertexBuffer ...

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.