For one thing, your positions and normals are not sized correctly.
Their sizes should be something like _modelMesh->vertices.size () * sizeof (GLfloat) * 4
and _modelMesh->normals.size () * sizeof (GLfloat) * 3
respectively. They are not the same size.
You also do not want to use sizeof (_modelMesh->vertices)
, because vertices
is a templated container. That will not give you the size of its contained elements, just the size of the instantiated std::vector <Vertex4f>
object (which is probably a couple of pointers).
Finally, I do not see anywhere in this code where you bind anything to GL_ELEMENT_ARRAY_BUFFER
.
Likewise, glBindBuffer(GL_ARRAY_BUFFER, _bufferID);
is not necessary in Model::draw (...)
, because the only time the thing bound to GL_ARRAY_BUFFER
matters is when you call gl...Pointer (...)
. From that point on, it does not matter what, if anything is bound to GL_ARRAY_BUFFER
; its only purpose is to tell the Pointer command which buffer's memory the pointer is relative to.