Added handling of automatic setting up of the contextID.

This commit is contained in:
Robert Osfield
2005-07-25 14:28:22 +00:00
parent 3c23a42f17
commit 384830d37e
5 changed files with 137 additions and 17 deletions

View File

@@ -99,18 +99,26 @@ GraphicsContextImplementation::GraphicsContextImplementation(Traits* traits)
// different graphics context so we have our own state.
setState(new osg::State);
if (sharedContext->getState())
{
getState()->setContextID( sharedContext->getState()->getContextID() );
incrementContextIDUsageCount( sharedContext->getState()->getContextID() );
}
else
{
getState()->setContextID( GraphicsContext::createNewContextID() );
}
// but we share texture objects etc. so we also share the same contextID
getState()->setContextID( sharedContext->getState() ? sharedContext->getState()->getContextID() : 1 );
_rs->realize(0, sharedContext->_rs->getGLContext());
_rs->realize( 0, sharedContext->_rs->getGLContext() );
}
else
{
static int count = 1;
// need to do something here....
setState(new osg::State);
getState()->setContextID(count++);
setState( new osg::State );
getState()->setContextID( GraphicsContext::createNewContextID() );
_rs->realize();
}