I am trying to render some old level data using the glDrawRangeElements() command. My vertices are set up correctly, my indices are set up correctly, but I can\'t seem to ge
First, let's talk about glDrawElements, because the Range version is just a modification of that. The count
is the number of indices to pull from the source index array to render. Each index pulled maps to a vertex. So if your count
is "29", then you are trying to render 29 vertices. This will only render 27 vertices if you use GL_TRIANGLES
, since each triangle requires three vertices. OpenGL will discard the extras.
So if you want to render 30 indices, you put 30 in as the count.
Now that we know how to use glDrawElements
, let's talk about glDrawRangeElements. When normally using glDrawElements
, you specify a location in the source index array to pull from. The indices
and count
parameters tell OpenGL where to find the indices. But the actual indices pulled from this array could be anywhere within the boundaries of the source vertex array indices.
glDrawRangeElements
allows you to give OpenGL a range (inclusive, because that makes sense) of vertex index values. What you are saying is that the indices it gets during this draw call will not exceed that range. This could allow the driver to perform useful optimizations. The start
value should be the lowest index value that will be gotten from the index array, and the end
should be the highest. It should not simply be the index of the first and last vertices.