Added context sharing support.

This commit is contained in:
Robert Osfield
2007-02-15 12:24:04 +00:00
parent 4f2474ece8
commit 3fe4be6e70
6 changed files with 55 additions and 9 deletions

View File

@@ -1005,8 +1005,17 @@ GraphicsWindowWin32::GraphicsWindowWin32( osg::GraphicsContext::Traits* traits )
if (valid())
{
setState( new osg::State );
getState()->setContextID( osg::GraphicsContext::createNewContextID() );
getState()->setGraphicsContext(this);
if (_traits.valid() && _traits->sharedContext)
{
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
}
else
{
getState()->setContextID( osg::GraphicsContext::createNewContextID() );
}
}
}
@@ -1401,6 +1410,16 @@ bool GraphicsWindowWin32::realizeImplementation()
{
init();
if (!_initialized) return false;
if (_traits.valid && _traits->sharedContext)
{
GraphicsWindowWin32* sharedContextWin32 = dynamic_cast<GraphicsWindowWin32*>(_traits->sharedContext);
if (sharedContextWin32)
{
makeCurrent();
wglShareLists( sharedContextWin32->getWGLContext(), getWGLContext() );
}
}
}
//