diff --git a/src/osgViewer/CompositeViewer.cpp b/src/osgViewer/CompositeViewer.cpp index a3e3e099f..f1d8a7ef8 100644 --- a/src/osgViewer/CompositeViewer.cpp +++ b/src/osgViewer/CompositeViewer.cpp @@ -119,6 +119,8 @@ bool CompositeViewer::readConfiguration(const std::string& filename) void CompositeViewer::addView(osgViewer::View* view) { + bool alreadyRealized = isRealized(); + bool threadsWereRuinning = _threadsRunning; if (threadsWereRuinning) stopThreading(); @@ -128,6 +130,33 @@ void CompositeViewer::addView(osgViewer::View* view) view->setFrameStamp(_frameStamp.get()); + if (alreadyRealized) + { + Contexts contexts; + if (view->getCamera()->getGraphicsContext()) + { + contexts.push_back(view->getCamera()->getGraphicsContext()); + } + for(unsigned int i=0; igetNumSlaves(); ++i) + { + if (view->getSlave(i)._camera->getGraphicsContext()) + { + contexts.push_back(view->getSlave(i)._camera->getGraphicsContext()); + } + } + + for(Contexts::iterator itr = contexts.begin(); + itr != contexts.end(); + ++itr) + { + if (!((*itr)->isRealized())) + { + (*itr)->realize(); + } + } + + } + if (threadsWereRuinning) startThreading(); } diff --git a/src/osgViewer/ViewerBase.cpp b/src/osgViewer/ViewerBase.cpp index be46ec882..ff5f85e45 100644 --- a/src/osgViewer/ViewerBase.cpp +++ b/src/osgViewer/ViewerBase.cpp @@ -372,6 +372,12 @@ void ViewerBase::startThreading() { osg::GraphicsContext* gc = (*citr); + if (!gc->isRealized()) + { + osg::notify(osg::INFO)<<"ViewerBase::startThreading() : Realizng window "<realize(); + } + gc->getState()->setDynamicObjectRenderingCompletedCallback(_endDynamicDrawBlock.get()); // create the a graphics thread for this context