Time for action—customizing the simulation loop

We are already very familiar with the run() method of the osgViewer::Viewer class. It was used many times to start a default simulation loop that loads the scene graph into the viewer and performs update, cull, and draw traversals on each frame.

But what does the run() method actually do? Is it possible to add some pre- and post-frame events for certain purposes? In this example, we are going to customize the simulation loop with a C++ while statement, as well as display the frame number after advancing one frame at a time.

Note that, the customized simulation loop cannot benefit from the on-demand rendering scheme and the maximum frame rate setting. They are only available when using the run() method. ...

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.