Added context sharing support.
This commit is contained in:
@@ -259,7 +259,9 @@ class GraphicsContextCarbon : public osg::GraphicsContext
|
||||
osg::notify(osg::WARN) << "GraphicsContext::realizeImplementation() aglChoosePixelFormat failed! " << aglErrorString(aglGetError()) << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_context = aglCreateContext (pixelformat, NULL);
|
||||
|
||||
if (!_context) {
|
||||
osg::notify(osg::WARN) << "GraphicsContext::realizeImplementation() aglCreateContext failed! " << aglErrorString(aglGetError()) << std::endl;
|
||||
return false;
|
||||
@@ -621,7 +623,17 @@ bool GraphicsWindowCarbon::realizeImplementation()
|
||||
}
|
||||
|
||||
// create the context
|
||||
_context = aglCreateContext (_pixelFormat, NULL);
|
||||
GraphicsWindowCarbon* sharedContextCarbon = dynamic_cast<GraphicsWindowCarbon*>(_traits->sharedContext);
|
||||
if (sharedContextCarbon)
|
||||
{
|
||||
_context = aglCreateContext (_pixelFormat, sharedContextCarbon->getAGLContext());
|
||||
}
|
||||
else
|
||||
{
|
||||
_context = aglCreateContext (_pixelFormat, NULL);
|
||||
}
|
||||
|
||||
|
||||
if (!_context) {
|
||||
osg::notify(osg::WARN) << "GraphicsWindowCarbon::realizeImplementation failed creating a context: " << aglGetError() << std::endl;
|
||||
return false;
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -422,13 +422,16 @@ void GraphicsWindowX11::init()
|
||||
}
|
||||
}
|
||||
|
||||
// need to pick up from traits
|
||||
GLXContext sharedGLContext = 0;
|
||||
|
||||
GraphicsWindowX11* sharedContextX11 = dynamic_cast<GraphicsWindowX11*>(_traits->sharedContext);
|
||||
if (sharedContextX11) sharedGLContext = sharedContextX11->getGLXContext();
|
||||
|
||||
_glxContext = glXCreateContext( _display, _visualInfo, sharedGLContext, True );
|
||||
if (sharedContextX11)
|
||||
{
|
||||
_glxContext = glXCreateContext( _display, _visualInfo, sharedContextX11->getGLXContext(), True );
|
||||
}
|
||||
else
|
||||
{
|
||||
_glxContext = glXCreateContext( _display, _visualInfo, NULL, True );
|
||||
}
|
||||
|
||||
if (!_glxContext)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user