I'm trying to use OSG 2.2 to create a main display of the primary scene
with a smaller "picture-in-picture"-style display of a completely
different scene in one of the corners.

The few examples that I've found so far have been for the older OSG 1.2
(using the old Producer interface).

I initially looked at using a slave camera, but got the impression from
some mailing list postings and the API that that was for a different
view of the same scene.

Based on that and other mailing list posts, I've been trying to use the
new CompositeViewer.
I've tried running the example "osgcompositeviewer" executable with
every combination of the -1, -2, and -3 flags possible from the code,
but I can only ever get it to show one scene on my single display.
http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/examples/osgcompositeviewer/osgcompositeviewer.cpp

If I use completely separate windows in my code, I can get each scene to
show up in a separate windows, but this isn't what I want.

By using an osg::GraphicsContext::Traits and
view->setUpViewOnSingleScreen(0), I've been able to get one scene to
show up in only the specified portion of the monitor, but I still can't
get two scenes on the monitor at the same time.

Below is a very stripped down skeleton of the basic code I've been
working with and trying to add different osg::GraphicsContext::Traits
and Viewports too.

==========
#include <osgViewer/CompositeViewer>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>

#include <osgDB/ReadFile>

#include <osgGA/GUIEventHandler>
#include <osgGA/StateSetManipulator>


int main (void)
{
  osg::ref_ptr<osg::Node> cessna = osgDB::readNodeFile("cessna.osg");
  osg::ref_ptr<osg::Node> cow = osgDB::readNodeFile("cow.osg");

  osgViewer::CompositeViewer viewer;

  // Main scene (fullscreen on a 1600x1200 screen)
  {
    osg::ref_ptr<osgViewer::View> view = new osgViewer::View();
    view->setSceneData(cessna.get());

    viewer.addView(view.get());
  }

  // Other scene in one corner ("picture-in-picture" style)
  {
    osg::ref_ptr<osgViewer::View> view = new osgViewer::View();
    view->setSceneData(cow.get());
    view->getCamera()->setViewport
      (new osg::Viewport(0, 512, 0, 512));

    viewer.addView(view.get());
  }

  return (viewer.run());
}
==========

I've tried putting the cessna in a viewport that doesn't overlap with
the cow viewport, but I only ever see either a fullscreen cessna.

Am I one the right track, or am I completely off base here?

Any pointers on how to achieve my desired picture-in-picture view of two
separate scenes would be greatly appreciated.

- Michael Berg

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to