Binding vertex buffers
When we draw a geometry, we need to specify data for vertices. At the very least, vertex positions are required, but we can specify other attributes such as normal, tangent or bitangent vectors, colors, or texture coordinates. This data comes from buffers created with a vertex buffer usage. We need to bind these buffers to specified bindings before we can issue drawing commands.
Getting ready
In this recipe, a custom VertexBufferParameters
type is introduced. It has the following definition:
struct VertexBufferParameters { VkBuffer Buffer; VkDeviceSize MemoryOffset; };
This type is used to specify the buffer's parameters: its handle (in the Buffer
member) and an offset from the start of the buffer's memory from which data should be taken (in the MemoryOffset
member).
How to do it...
- Take the handle of a command buffer that is in a recording state and use it to initialize a variable of type
VkCommandBuffer
namedcommand_buffer
. - Create a variable of type
std::vector...