I have been doing some work with open gl on the android platform recently and I have been following this tutorial http://blog.jayway.com/2010/02/15/opengl-es-tutorial-for-android-%E2%80%93-part-v/ .
However there is one thing that isn’t really explained in the tutorial and that is what is an index or Indices. So my question is what is meant by indices? what do they do and how do they fit into drawing 3D shapes.
I have been doing some work with open gl on the android platform recently
Share
Usually you’ll have your vertices in a
float[]in the orderx, y, z, x, y, z.... Imagine for a second that each set ofx, y, zis a single element in an array. An index is the location of a vertex in that new array.So let’s say you have the vertices for something simple, a square:
The proper way to draw the square as
GL_TRIANGLESusing indices would be by using the indices0, 1, 2, 0, 2, 3, where0, 1, 2create the first triangle and0, 2, 3create the second triangle.