-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
OpenSceneGraph 3.0: Beginner's Guide
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 and encapsulate OpenGL's glDrawElements() function, with different data types. The index array saves indices of vertex array elements. In this case, the cube's vertex array is able to be resized to eight, with an associated indexing primitive set.
The osg::DrawElements* classes are designed to work just like std::vector, so any vector-related...
Change the font size
Change margin width
Change background colour