From 52e036f425b71bf1d6c4f5bc54eefd6436464a56 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 6 May 2005 19:44:24 +0000 Subject: [PATCH] Added handling of sharing of graphics context data which is now supported by Producer. You can get the osgProducer::Viewer to share graphics contexts by using the env var OSG_SHARE_GRAPHICS_CONTEXTS set to ON or OFF i.e. setenv OSG_SHARE_GRAPHICS_CONTEXTS ON --- src/osgProducer/OsgCameraGroup.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/osgProducer/OsgCameraGroup.cpp b/src/osgProducer/OsgCameraGroup.cpp index 75634c941..94f4c1681 100644 --- a/src/osgProducer/OsgCameraGroup.cpp +++ b/src/osgProducer/OsgCameraGroup.cpp @@ -212,8 +212,16 @@ void OsgCameraGroup::_init() if (str) { if (strcmp(str,"SingleThreaded")==0) _thread_model = SingleThreaded; - else _thread_model = ThreadPerCamera; + else if (strcmp(str,"ThreadPerCamera")==0) _thread_model = ThreadPerCamera; } + + str = getenv("OSG_SHARE_GRAPHICS_CONTEXTS"); + if (str) + { + if (strcmp(str,"ON")==0) Producer::RenderSurface::shareAllGLContexts(true); + else if (strcmp(str,"OFF")==0) Producer::RenderSurface::shareAllGLContexts(false); + } + _scene_data = NULL; _global_stateset = NULL; @@ -453,7 +461,11 @@ bool OsgCameraGroup::realize() if (_renderSurfaceStateMap.count(rs)==0) { _renderSurfaceStateMap[rs] = sv->getState(); - sv->getState()->setContextID(contextID++); + sv->getState()->setContextID(contextID); + + // if we aren't share OpenGL objects between graphics contexts then need to increment the contextID + // to ensure that the OSG generates seperate objects for each graphics context. + if (!Producer::RenderSurface::allGLContextsAreShared()) ++contextID; } else {