So I have a simple cube "mesh":
the 6 cube faces are 12 triangles, hence 36 "vertices" organized as 36 indices reusing 8 unique vertex positions, 6 unique vertex normals and 4 unique vertex-texcoords.
This indexed mesh is stored in a VBO/IBO pair that may have other meshes before or after it, hence base-vertex is advisable here.
Now I can render the full cube completely and correctly in a single draw call like this:
gl.DrawElementsBaseVertex(
gl.TRIANGLES, gl.Sizei(36), gl.UNSIGNED_INT,
gl.PtrOffset(nil, uintptr(myMeshIndexBufOffset)),
gl.Int(myMeshIndexBufBaseIndex))
However, now I just want to draw the "first 4 triangles" (aka the "first" 2 cube-faces) -- with 4 draw calls rather than 1 (as texture binds may happen in between) and I'm really at a loss as to how to properly specify the count and basevertex arguments.
Well for a single triangle, I'll just have to assume I need to specify a count of 3. For 12 triangles I had to use 36 to successfully render the full complete cube, so 3 for a single triangle makes sense. It then picks 3 "index entries" (here defined as three uint32s per entry) from the element array. Correct?
But I just can't figure out --neither through logical reasoning nor through experimentation-- how the base-vertex is now specified here. Specifically I'll need to add my own offset to the "cube-mesh base-index" which is known. If I were to glDrawElementsBaseVertex() all individual 12 triangles separately in a loop:
for i := 0; i < 12; i++ {
gl.DrawElementsBaseVertex(
gl.TRIANGLES, gl.Sizei(3), gl.UNSIGNED_INT,
gl.PtrOffset(nil, uintptr(myMeshIndexBufOffset)),
(i * fooBar) + gl.Int(myMeshIndexBufBaseIndex))
}
then... does anyone have any insight as to what exactly fooBar above should represent?
It's annoying: really, in theory I was pretty sure I did understand the glDrawElementsBaseVertex specification quite completely, yet in practice nothing yields properly separately rendered select individual triangles.