Binding an index buffer
To draw a geometry, we can provide the list of vertices (and their attributes) in two ways. The first way is a typical list, in which vertices are read one after another. The second method requires us to provide additional indices that indicate which vertices should be read to form polygons. This feature is known as indexed drawing. It allows us to reduce the memory consumption as we don't need to specify the same vertices multiple times. It is especially important when we have multiple attributes associated with each vertex, and when each such vertex is used across many polygons.
Indices are stored in a buffer called an index buffer, which must be bound before we can draw an indexed geometry.
How to do it...
- Store the command buffer's handle in a variable of type
VkCommandBuffer
namedcommand_buffer
. Make sure it is in a recording state. - Take the handle of the buffer in which the indices are stored. Use its handle to initialize a variable of type
VkBuffer
namedbuffer...