From fe61dcac69be4f09d761aba35f0c6ac7d9f3b2c8 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 1 Feb 2012 17:42:42 +0000 Subject: [PATCH] From Colin McDonald, "I have an application with multiple windows. They share GL objects between the contexts, using the GraphicsContext::Traits sharedContext and setting the same contextID. When one of these shared contexts is closed, GraphicsContext::close deletes all GLObjects for that contextID, regardless of the fact that they are shared. This means that all of the other contexts sharing the objects have to recompile them. The attached tweak makes GraphicsContext::close a bit less brutal for shared contexts. I have also changed a misleading diagnostic message. " --- src/osg/GraphicsContext.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/osg/GraphicsContext.cpp b/src/osg/GraphicsContext.cpp index 5476fb564..5385e8bd9 100644 --- a/src/osg/GraphicsContext.cpp +++ b/src/osg/GraphicsContext.cpp @@ -304,9 +304,9 @@ void GraphicsContext::incrementContextIDUsageCount(unsigned int contextID) { OpenThreads::ScopedLock lock(s_contextIDMapMutex); - OSG_INFO<<"GraphicsContext::incrementContextIDUsageCount("<getContextID()); + osg::deleteAllGLObjects(_state->getContextID()); - OSG_INFO<<"Done delete of GL objects"<getContextID()); + } _state->reset(); @@ -561,7 +570,7 @@ void GraphicsContext::close(bool callCloseImplementation) // now discard any deleted deleted OpenGL objects that the are still hanging around - such as due to // the the flushDelete*() methods not being invoked, such as when using GraphicContextEmbedded where makeCurrent // does not work. - if (_state.valid()) + if ( !sharedContextExists && _state.valid()) { OSG_INFO<<"Doing discard of deleted OpenGL objects."<