Added realize of new graphics contexts to handle new views being added with
unrealized windows
This commit is contained in:
@@ -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; i<view->getNumSlaves(); ++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();
|
||||
}
|
||||
|
||||
|
||||
@@ -372,6 +372,12 @@ void ViewerBase::startThreading()
|
||||
{
|
||||
osg::GraphicsContext* gc = (*citr);
|
||||
|
||||
if (!gc->isRealized())
|
||||
{
|
||||
osg::notify(osg::INFO)<<"ViewerBase::startThreading() : Realizng window "<<gc<<std::endl;
|
||||
gc->realize();
|
||||
}
|
||||
|
||||
gc->getState()->setDynamicObjectRenderingCompletedCallback(_endDynamicDrawBlock.get());
|
||||
|
||||
// create the a graphics thread for this context
|
||||
|
||||
Reference in New Issue
Block a user