20,741
edits
m (→Views: more best practices from osg-users) |
|||
Line 79: | Line 79: | ||
* CompositeViewer and Viewer share much of their implementation, the only key difference is that Viewer "is a" View, while CompositeViewer has a list of Views. All the event handling, camera manipulator and scene graph setting is done a the View level so has identical API to access. <ref>https://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg17372.html</ref> | * CompositeViewer and Viewer share much of their implementation, the only key difference is that Viewer "is a" View, while CompositeViewer has a list of Views. All the event handling, camera manipulator and scene graph setting is done a the View level so has identical API to access. <ref>https://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg17372.html</ref> | ||
=== Views === | === Views === | ||
For example, you could have a working set of View's that share the scene graph, and share | |||
the same graphics context. All these Views would be added to the | |||
CompositeViewer. At start up these View's would be disabled by setting their | |||
View Camera's NodeMask to 0x0. | |||
When you need to render a View for a client you'd enable a View of one is | |||
attached and not enabled, enable by setting the Camera's NodeMask to | |||
0xffffffff. If you run out of View then simply create a new one for the | |||
purpose. Potentially you could do this on demand - so have none at start | |||
up. | |||
When you no longer need a View you could remove it, but it's lighter to | |||
just disable it via the NodeMask trick. | |||
With this approach you aren't creating/deleting graphics contexts, will | |||
lower memory usage and you'll get better performance.<ref>https://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg63061.html</ref> | |||
* The right way to remove a view is outside of frame(). Not from an event handler from within the view, this will crash as you'll be deleting the object you are doing the work from.<ref>https://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg35639.html</ref> | * The right way to remove a view is outside of frame(). Not from an event handler from within the view, this will crash as you'll be deleting the object you are doing the work from.<ref>https://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg35639.html</ref> | ||