Hi Gianni,

I don't have answers for the specifics of your usage case, but I vaguely
recall discussing on osg-users the issue of adding and removing views but
retaining a ref_ptr<> to the removed views.  I certainly applied fixes to
avoid problems but don't recall enough of the details if it matches your
usage case.

If you aren't already using it it might be worth looking at OSG-3.2.x to
see if that helps.

Robert.


On 4 December 2013 15:15, Gianni Ambrosio <[email protected]> wrote:

> OK, it seems that there is something odd in osg code.
>
> As found in another topic views that uses the same graphic context don't
> need to be added to the compisite viewer at all but a simple instantiation
> make them appear on the composite viewer: that seems counterintuitive.
> Moreover the compositeviewer example uses addView() even if the graphic
> context is the same for all viewes: so it seems the intent was to use
> addView to add a view not just create it!
> The code of removeView() (and its counterpart addView()) behaves just like
> the view should be removed from the composite viewer but indeed it does not
> happen. I don't think the intent of a public API like addView/removeView
> was implemented with such a behavior in mind.
>
> But there's something even more strange. If an added view is kept alive by
> a ref_ptr (see example below) the removeView() does not work as expected.
> On the contrary, removing comments from the following code, removeView
> works fine.
>
> Gianni
>
>
> Code:
>
> #include <osgViewer/CompositeViewer>
> #include <osg/GraphicsContext>
>
> int main( int argc, char** argv )
> {
>     osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
> osg::GraphicsContext::Traits;
>     traits->x = 100;
>     traits->y = 100;
>     traits->width = 500;
>     traits->height = 300;
>     traits->depth = 16;
>     traits->windowDecoration = true;
>     traits->supportsResize = true;
>     traits->doubleBuffer = true;
>     osg::ref_ptr<osg::GraphicsContext> graphicscontext =
> osg::GraphicsContext::createGraphicsContext(traits);
>
>     osgViewer::CompositeViewer viewer;
>
>     osgViewer::View * redView = new osgViewer::View();
>     redView->setSceneData(new osg::Group);
>     redView->getCamera()->setClearColor(osg::Vec4f(0.5,0,0,1));
>     redView->getCamera()->setViewport(50, 50, 300, 100);
>     redView->getCamera()->setGraphicsContext(graphicscontext);
>
>     osg::ref_ptr<osgViewer::View> greenView = new osgViewer::View();
>     //osgViewer::View * greenView = new osgViewer::View();
>     greenView->setSceneData(new osg::Group);
>     greenView->getCamera()->setClearColor(osg::Vec4f(0,0.5,0,1));
>     greenView->getCamera()->setViewport(100, 100, 300, 100);
>     greenView->getCamera()->setGraphicsContext(graphicscontext);
>
>     viewer.addView(redView);
>     viewer.addView(greenView);
>     viewer.removeView(greenView);
>
>     return viewer.run();
> }
>
>
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=57547#57547
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to