O'Reilly logo

Learning Vulkan by Parminder Singh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required