Buffers
Now we need to take these vertices and indices and get them into arrays that the GPU can understand. This is done through the use of buffers, which refer to blocks of memory that the GPU can use for a variety of different tasks.
Direct3D provides a couple of different types of buffers, each with their own purpose in the pipeline. The most commonly used buffers include the following:
- Vertex buffers
- Index buffers
- Constant buffers
As you may have gathered, we use vertex and index buffers to store the data we need for rendering.
Building the vertex and index buffers
To create these buffers, we need to build up an array of the data, being careful to control the layout of each vertex. Later on we'll tell the GPU how to read the data, so we can make sure that we know how it will be laid out in memory. To do this, we need to create a structure definition that outlines the layout of each vertex. A simple vertex structure could look like the following:
typedef struct PositionNormalVertex {...