Version 3 (modified by osg, 6 years ago)

--

Views and Viewers

Basic Description

There is a history and rationale behind the osgViewer library. This page is meant to describe how to use the current Viewers and Views.

When choosing an OpenSceneGraph provided Viewer, one has two choices: Viewer or CompositeViewer. Both are derived off of osgViewer::ViewerBase. ViewerBase provides functionality such as controlling stats, threading, and frame calls.

Views themselves can contain multiple Cameras. Among other things, Views control a Scene, DisplaySettings, Event Handlers, and Camera Manipulators.

osgViewer::Viewer along with being a ViewerBase is also a View. This simplifies the setup and interface if one is interested in a single view.

osgViewer::!CompositeViewer, in contrast with Viewer, actually contains a list of multiple Views. This gives more versatility to the programmer but with more work to access View functionality.

Which Viewer to Use

So which Viewer class is right for your app? This is discussed in detail on this page.

Event and Pick Handling

TODO: This is just a stub.

Windowing

Windows are created for each GraphicsContext created. When using some of helper funcions for osgView::View, such as setUpViewAcrossAllScreens(), setUpViewOnSingleScreen(), or setUpViewInWindow(), the graphics context with a new window will be created for each call. Therefore, using some combination of these calls with a CompositeViewer with multiple Views would produce multiple windows. If one did not want multiple windows or maybe didn't want window decorations, one can setup the Traits themselves. A single window with multiple views can be achieved by setting Traits::sharedContext to a previously created context. And, the decorations can be turned of with Traits::windowDecoration set to false.

Examples of setting up windows and contexts can be found in the osgwindows and osgcamera examples among others.