Memblocks

Creating our MemBlock

In order to create a mesh in AGK2, we must first define our mesh in a memblock. A memblock is just a block of memory that contains any data we want. When we use a memblock to store mesh data, we call it a mesh memblock. To create the memblock, we will use the CreateMemblock() command. Add this to your code, before the do/loop

//first we will create a memblock to hold the mesh
memblock = CreateMemblock(160)

You might wonder where we get the value 160 from. That is the total size in bytes of our mesh memblock structure. It includes the header, the vertex data, and the index data. The size can vary depending on the number of vertices, number of indices, and the number of attributes present. Rather than calculating all this before hand, it might be easier to store your mesh information in types and arrays, then calculating the size from that. This example is simple enough that we can calculate the size as we go along and adjust the final size accordingly.

Created with Tutorial Markup (c)2018 James Chamblin