Dealing with missing glDrawElementsBaseVertex in OpenGL ES

I'm working on porting Direct3D terrain rendering to Android and just found out that OpenGL doesn't have an equivalent for DrawIndexedPrimitive BaseVertexIndex until version 3.2 introduced the glDrawElementsBaseVertex method. This method is not available in OpenGL ES.

The D3D terrain renderer uses a single large vertex buffer to hold active terrain in LRU mode. The same 16-bit indices are used to draw each patch.

Given the lack of a base vertex index in OpenGL ES, I cannot use the same indices to draw each patch. Also, the buffer is too large for 16-bit absolute indices. The alternatives that I have identified are as follows:

  • Use one VBO or vertex array per patch.
  • Use 32-bit indexes and generate new indexes for every block in VBO.
  • Stop using indexing and vertex replication as needed. Note that most of the vertices appear in six triangles. Going into triangular stripes might help, but it still doubles the number of vertices.

None of them seem to be very effective compared to what was possible in D3D. Are there any other alternatives?


source to share

1 answer

You haven't specified the exact location of your VBOs data, but if the base vertex offset is not negative, you can apply the offset when binding the VBO to the vertex attribute (glVertexAttribPointer).



All Articles