Indexing primitives
The osg::DrawArrays
works fine when reading vertex data straight through the arrays, without any skipping and hopping. However, it tends to be a little inefficient if there are lots of shared vertices. For example, in order to make osg::DrawArrays
draw a cube with eight vertices in the GL_TRIANGLES
mode, the vertex array should repeat each vertex a couple of times and should increase the array size to 36 (12 triangle faces) at last:

The osg::DrawElementsUInt
class, as well as osg::DrawElementsUByte
and osg::DrawElementsUShort
classes, are used as index arrays in order to solve the above problem. They all derive from osg::PrimitiveSet ...
Get OpenSceneGraph 3.0 now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.