PDA

View Full Version : glDrawElements mismatched arrays



Pyramus
03-20-2012, 04:46 PM
Hello

If I am drawing 2 cubes I need 16 vertices and 24 indices.

But then:

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, _vertexBuffer);

gl.glDrawElements(GL10.GL_TRIANGLES, _nrOfVertices, GL10.GL_UNSIGNED_SHORT, _indexBuffer);

Only shows the first cube and two faces of the second.
It's clearly only using 16 of the indices as well as the vertices.

Won't there usually be more indices than vertices and what can I do to fix this?

Sorry for such a newb question. I have searched for an answer.

Thank you.

juggernaut
03-20-2012, 05:23 PM
Have you tried _nrOfIndices, not _nrOfVertices?

Pyramus
03-20-2012, 05:29 PM
Gawd, i'm stupid!

I did but I was treating each index triple as 1, so was out by a factor of 3.

Thank you.