diff --git a/src/osg/GraphicsContext.cpp b/src/osg/GraphicsContext.cpp index 32cfb28c1..bf6bce280 100644 --- a/src/osg/GraphicsContext.cpp +++ b/src/osg/GraphicsContext.cpp @@ -454,29 +454,35 @@ void GraphicsContext::close(bool callCloseImplementation) { osg::notify(osg::INFO)<<"Closing still viable window "<getContextID()="<<_state->getContextID()<getFrameStamp()?_state->getFrameStamp()->getReferenceTime():0.0; + // flush all the OpenGL object buffer for this context. + double availableTime = 100.0f; + double currentTime = _state->getFrameStamp()?_state->getFrameStamp()->getReferenceTime():0.0; - osg::FrameBufferObject::flushDeletedFrameBufferObjects(_state->getContextID(),currentTime,availableTime); - osg::RenderBuffer::flushDeletedRenderBuffers(_state->getContextID(),currentTime,availableTime); - osg::Texture::flushAllDeletedTextureObjects(_state->getContextID()); - osg::Drawable::flushAllDeletedDisplayLists(_state->getContextID()); - osg::Drawable::flushDeletedVertexBufferObjects(_state->getContextID(),currentTime,availableTime); - osg::VertexProgram::flushDeletedVertexProgramObjects(_state->getContextID(),currentTime,availableTime); - osg::FragmentProgram::flushDeletedFragmentProgramObjects(_state->getContextID(),currentTime,availableTime); - osg::Program::flushDeletedGlPrograms(_state->getContextID(),currentTime,availableTime); - osg::Shader::flushDeletedGlShaders(_state->getContextID(),currentTime,availableTime); + osg::FrameBufferObject::flushDeletedFrameBufferObjects(_state->getContextID(),currentTime,availableTime); + osg::RenderBuffer::flushDeletedRenderBuffers(_state->getContextID(),currentTime,availableTime); + osg::Texture::flushAllDeletedTextureObjects(_state->getContextID()); + osg::Drawable::flushAllDeletedDisplayLists(_state->getContextID()); + osg::Drawable::flushDeletedVertexBufferObjects(_state->getContextID(),currentTime,availableTime); + osg::VertexProgram::flushDeletedVertexProgramObjects(_state->getContextID(),currentTime,availableTime); + osg::FragmentProgram::flushDeletedFragmentProgramObjects(_state->getContextID(),currentTime,availableTime); + osg::Program::flushDeletedGlPrograms(_state->getContextID(),currentTime,availableTime); + osg::Shader::flushDeletedGlShaders(_state->getContextID(),currentTime,availableTime); - osg::notify(osg::INFO)<<"Done Flush "<reset(); - - releaseContext(); + _state->reset(); + + releaseContext(); + } + else + { + osg::notify(osg::INFO)<<"makeCurrent did not succedd, could not do flush/deletion of OpenGL objects."<initializeExtensionProcs(); }