Hi,

El Miércoles 19 Noviembre 2008ES 14:08:14 Robert Osfield escribió:
> HI Alberto,
>
> You would be best to put the viewer.realize() till after all the camera
> setup.
>
> Robert.

Putting viewer.realize() just before viewer.run() makes the slave views not 
showing on 2.4 nor SVN. I have to return to StatsHandler and osgWidget code 
to see why my code is behaving different...

Regards,

Alberto


> On Wed, Nov 19, 2008 at 12:33 PM, Alberto Luaces <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I'm having some trouble trying to set some slave cameras, acting as HUDs.
> > I have written a small program showing how I'm setting the graph. When
> > running with 2.4.0, none of the slave views are shown. When compiling
> > against SVN, the two are shown, but a crash happens when pressing 's'
> > several times, so I have to be doing something wrong to get such
> > different behaviours with several versions of the library. Currently
> > osgWidget is not an option for me as I'm tied to 2.4.0 for this project.
> > Here is the tiny code:
> >
> > #include <osgViewer/Viewer>
> > #include <osgViewer/ViewerEventHandlers>
> > #include <osgDB/ReadFile>
> >
> > void prepareCamera(osg::Camera *c, osgViewer::Viewer &v)
> > {
> >  c->setGraphicsContext(v.getCamera()->getGraphicsContext());
> >  c->setProjectionMatrix(osg::Matrix::ortho2D(0,1024,0,768));
> >
> >  c->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
> >  c->setViewMatrix(osg::Matrix::identity());
> >
> >  c->setAllowEventFocus(false);
> >
> >  v.addSlave(c, false);
> > }
> >
> > int main()
> > {
> >  osg::Camera *c1, *c2;
> >
> >  c1 = new osg::Camera;
> >  c2 = new osg::Camera;
> >
> >  osgViewer::Viewer v;
> >  v.addEventHandler(new osgViewer::StatsHandler());
> >  v.realize();
> >
> >  prepareCamera(c1, v);
> >  c1->setViewport(200,100,1024+200,768+100);
> >  c1->setClearColor(osg::Vec4(1.0,0.0,0.0,1.0));
> >  c1->setRenderOrder(osg::Camera::POST_RENDER);
> >
> >  prepareCamera(c2, v);
> >  c2->setViewport(0,0,1024,768);
> >  c2->setClearColor(osg::Vec4(0.0,1.0,0.0,1.0));
> >  c2->setRenderOrder(osg::Camera::POST_RENDER);
> >
> >  v.getCamera()->setClearColor(osg::Vec4(0.3,0.3,0.3,0.0));
> >  v.getCamera()->setRenderOrder(osg::Camera::PRE_RENDER);
> >
> >  v.run();
> >
> >  return 0;
> > }
> >
> >
> > Thanks,
> >
> > Alberto



_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to