Creating geometry with a buffer resource

In this section, we will create a simple geometrical shape--a triangle. This will be stored in the GPU memory with the help of a buffer resource. Most applications will consume buffers through uniform or storage blocks. The implementation of a buffer resource is very similar to that of an image resource, except the fact that here we would not need to create the buffer view (VkBufferView).

Preparing geometry data

Create MeshData.h and define the geometry data inside it. Declare the following structures:

/*---------------------MeshData.h-----------------------*/

// Mesh data structure and Vertex Data 
struct VertexWithColor 
{ 
    float x, y, z, w;   // Vertex Position 
    float r, g, b, a;   // Color format Red, Green, ...

Get Learning Vulkan 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.