Using a single viewer

OSG supports the single viewer class osgViewer::Viewer for holding a view on a single scene. It uses the setSceneData() method to manage the scene graph's root node, and run() to start the simulation loop, in which the scene is rendered again and again. The frame buffer is therefore continuously updated by the result of every rendering cycle, so called a frame.

Besides that, the viewer also contains an osg::Camera object as the main camera, which we discussed before. The view matrix of the camera is controlled by the viewer's internal osgGA::CameraManipulator object. Meanwhile, user input events are also received and handled by the viewer, via a list of osgGA::GUIEventHandler handlers. The viewer can even be set up in full ...

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.