He’s using one VBO per vertex attribute, so passing in stride=0 and offset=0 is valid. They’re only relevant when having multiple attributes packed in a single VBO.
- Stride is the byte distance between each element. Here you’d pass in how many byte each vertex takes. Passing 0 tells OpenGL that the data is tightly packed.
- Offset is simply the first byte index OpenGL should start reading from.
For a VBO only containing a vec3 position and a 32-bit RGBA color for each vertex, you’d set up the attributes like this:
int vertexSize = 3*4 + 4;
glVertexAttribPointer(positionLocation, 3, GL11.GL_FLOAT, false, vertexSize, 0);
glVertexAttribPointer(colorLocation, 4, GL11.GL_UNSIGNED_BYTE, true, vertexSize, 3*4);
Back to Tyecon’s code then…
Your code might indeed by CPU limited. How many times is calculateModel() called in Matter? The fact that calculateModel() is called from setPosition/Rotation/Scale() is a bit worrying. That code might be run 3 times per update or more if you move your objects around a lot.
A simple test you can do to determine if you’re CPU or GPU limited is to simply comment out glDrawArrays() in Mesh.Draw() but leave everything else intact. If the program runs at almost the same speed as before, you’re CPU limited. If you get a big FPS boost, you’re GPU limited.