Added realize of new graphics contexts to handle new views being added with

unrealized windows
This commit is contained in:
Robert Osfield
2008-06-28 16:59:26 +00:00
parent fec2a8fabe
commit 8820d0bb1d
2 changed files with 35 additions and 0 deletions

View File

@@ -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();
}

View File

@@ -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