I have been rendering my height maps using client-side index buffers for each triangle strip in each patch (height map is divided into smaller blocks a la Geomipmapping). I am now trying to move these index buffers over to IBOs, but have come across a real puzzling problem.
For simplicity, I’m only rendering a single 32x32 patch.
The picture below is using client-side index buffers:
… and here is what happens if I try to move these buffers to an IBO:
What I couldn’t get to show from this picture is the vertices on the last column seem to connect to the first vertex in the patch.
The confusing part to me is these same client-side index buffers (that work fine) are the data being passed to glBufferData, shown below:
// "indexBuffers" are the client-side buffers
protected void initIBOs(GL gl)
{
for(int i = 0; i < this.indexBuffers.length; i++)
{
gl.glGenBuffers(1, this.iboIDs[i]);
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, this.iboIDs[i].get(0));
gl.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, this.indexBuffers[i].capacity(), this.indexBuffers[i], GL.GL_STATIC_DRAW);
}
}
Here is how the IBOs are being rendered:
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, this.vboManager.getBufferID());
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0);
// just one block as a test
this.blocks[0][0].renderWithIBOs(gl);
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
. . .
protected void renderWithIBOs(GL gl)
{
// number of vertices in each triangle strip
int numVertices = indexBuffers[0].capacity();
for(int i = 0; i < this.iboIDs.length; i++)
{
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, this.iboIDs[i].get(0));
gl.glDrawRangeElements(GL.GL_TRIANGLE_STRIP, 0, numVertices-1, numVertices, GL.GL_UNSIGNED_INT, 0);
}
}
Has anyone experienced such a problem?