Storing array data

As already mentioned in earlier chapters, OSG supports vertex arrays and VBO to speed up the rendering process. To manage the vertex data used in these two mechanisms, OSG defines a basic osg::Array class and a few derived classes for commonly used array and index array types.

The osg::Array class can't be instantiated, but it declares interfaces to exchange with OpenGL calls and buffer data modifiers. Its subclasses (osg::Vec2Array, osg::Vec3Array, osg::UIntArray, etc.) inherit the characteristics of the Standard Template Library vector class, and can thus make use of all of the std::vector members, including push_back(), pop_back(), size(), and STL algorithms and iterators.

The following code will add a three-element vector ...

Get OpenSceneGraph 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.