glDrawElements on vbo

This topic is 4522 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

No problem using glDrawArrays on a vbo or glDrawElements in immediate mode but I can't get anything drawn using glDrawElements on a vbo.
	glGenBuffers(2, &buf[0]);
glBindBuffer(GL_ARRAY_BUFFER, buf[0]);
glBufferData(GL_ARRAY_BUFFER, HEIGHTM_WIDTH*HEIGHTM_WIDTH*TUXYZ*sizeof(float),
&mesh[0][0][0], GL_STATIC_DRAW);
glInterleavedArrays(GL_T2F_V3F, 0, NULL );
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buf[1]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, HEIGHTM_WIDTH*2*sizeof(float),
&meshIndices[0][0], GL_STATIC_DRAW);

glDrawElements(GL_TRIANGLE_STRIP, HEIGHTM_WIDTH*2, GL_UNSIGNED_INT, NULL);
I keep checking my arrays and indices, I think they are good. Did I skip a step in setting up the indices array? Note that I'm just drawing the first triangle strip in this height map, which was fine in the other modes.

Share on other sites
The only obvious thing I can see wrong with that is the use of "sizeof(float)" when specifying the size of the index array, but that shouldn't make any difference as it should match "sizeof(unsigned int)" anyway.
Maybe more code would help.

• 16
• 13
• 23
• 10
• 19