Table of Contents

NervLand: Vertex buffers, bindings and attributes

In the last post, we introduced suppport for the Vulkan Memory Allocator to take care of our memory allocations. With this in place, we can now try to extend a bit on our display system and try to vertex buffers to provided the data we want to draw instead of hardcoding the value in our shader. And in this process we can start the design a subsystem to create various simple shapes like a plane, a cube, a sphere, etc.

Preparing the vertex buffer

I must add those attributes in the proper order to compute the “offset” correctly, but I think that's an acceptable constraint

Building host visible buffers

Writting data inside VertexBuffers

Drawing a first triangle with a VertexBuffer

We should also remember here that we can create a FloatList directly from a lua table provided as constructor argument 😉!

And now time to run our first test with those changes (drum rolls...) 🥁

Adding colors to our triangle

Normally it would make more sense to add the colors as uint8 values, but for this first try let's simple use a larger float32 array.

Reconsidering the color format

And now I think this is good enough for this session ;-) See you next time!