Hey guys,
I’ve a little problem with an indexed vbo. The call to glDrawElements is causing a crash.
glDrawElements(GL_TRIANGLES,CurMesh[i]->GetIndexCount(),GL_UNSIGNED_INT,0);
That’s the call. CurMesh[i]->GetIndexCount() returns the number of indices, in this case 36. The Mesh is a simple Cube, so it has only 8 vertices and is made of triangles, which sums up to 36 indices.
The code to build the vbo looks like this:
glGenBuffers(1,&VertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER,VertexBuffer);
glBufferData(GL_ARRAY_BUFFER, nVertices*12,pVertices,GL_STATIC_DRAW);
glGenBuffers(1,&NormalBuffer);
glBindBuffer(GL_ARRAY_BUFFER,NormalBuffer);
glBufferData(GL_ARRAY_BUFFER, nNormals*12,pNormals,GL_STATIC_DRAW);
glGenBuffers(1,&IndexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, nIndexes*4, pIndexes, GL_STATIC_DRAW);
nNormals holds the number of normals(36, one normal for each index) and nVertices holds the number of vertices (8, it’s a simple cube). Both values are multiplied by 12 (3 floats and 4 bytes).
Can you guys help me? I have a book about this next to me, but I don’t see any mistakes…
Thanks in advance
bye
Shelling