Added CameraNode::releaseGLObejcts() to help in clean up, and changed the
ordering in SceneView::flushDeleteGLObjects() so that fbo's are deleted before any texture objects they use are deleted.
This commit is contained in:
parent
b835ec9ee9
commit
53ee0ce3ec
@ -309,6 +309,11 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
|
||||
|
||||
OpenThreads::Mutex* getDataChangeMutex() const { return &_dataChangeMutex; }
|
||||
|
||||
/** If State is non-zero, this function releases any associated OpenGL objects for
|
||||
* the specified graphics context. Otherwise, releases OpenGL objexts
|
||||
* for all graphics contexts. */
|
||||
virtual void releaseGLObjects(osg::State* = 0) const;
|
||||
|
||||
public:
|
||||
|
||||
/** Transform method that must be defined to provide generic interface for scene graph traversals.*/
|
||||
|
@ -223,6 +223,14 @@ void CameraNode::detach(BufferComponent buffer)
|
||||
_bufferAttachmentMap.erase(buffer);
|
||||
}
|
||||
|
||||
void CameraNode::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
if (state) const_cast<CameraNode*>(this)->_renderingCache[state->getContextID()] = 0;
|
||||
else const_cast<CameraNode*>(this)->_renderingCache.setAllElementsTo(0);
|
||||
|
||||
Transform::releaseGLObjects(state);
|
||||
}
|
||||
|
||||
|
||||
bool CameraNode::computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
|
||||
{
|
||||
|
@ -741,6 +741,7 @@ void OsgCameraGroup::cleanup_frame()
|
||||
++itr)
|
||||
{
|
||||
(*itr)->getSceneView()->releaseAllGLObjects();
|
||||
(*itr)->getSceneView()->setRenderStage(0);
|
||||
(*itr)->setCleanUpOnNextFrame(true);
|
||||
}
|
||||
|
||||
|
@ -746,6 +746,8 @@ void SceneView::flushAllDeletedGLObjects()
|
||||
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);
|
||||
@ -753,8 +755,6 @@ void SceneView::flushAllDeletedGLObjects()
|
||||
osg::FragmentProgram::flushDeletedFragmentProgramObjects(_state->getContextID(),currentTime,availableTime);
|
||||
osg::Program::flushDeletedGlPrograms(_state->getContextID(),currentTime,availableTime);
|
||||
osg::Shader::flushDeletedGlShaders(_state->getContextID(),currentTime,availableTime);
|
||||
osg::RenderBuffer::flushDeletedRenderBuffers(_state->getContextID(),currentTime,availableTime);
|
||||
osg::FrameBufferObject::flushDeletedFrameBufferObjects(_state->getContextID(),currentTime,availableTime);
|
||||
}
|
||||
|
||||
void SceneView::flushDeletedGLObjects(double& availableTime)
|
||||
@ -762,6 +762,9 @@ void SceneView::flushDeletedGLObjects(double& availableTime)
|
||||
_requiresFlush = false;
|
||||
|
||||
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::flushDeletedTextureObjects(_state->getContextID(),currentTime,availableTime);
|
||||
osg::Drawable::flushDeletedDisplayLists(_state->getContextID(),availableTime);
|
||||
osg::Drawable::flushDeletedVertexBufferObjects(_state->getContextID(),currentTime,availableTime);
|
||||
@ -769,8 +772,6 @@ void SceneView::flushDeletedGLObjects(double& availableTime)
|
||||
osg::FragmentProgram::flushDeletedFragmentProgramObjects(_state->getContextID(),currentTime,availableTime);
|
||||
osg::Program::flushDeletedGlPrograms(_state->getContextID(),currentTime,availableTime);
|
||||
osg::Shader::flushDeletedGlShaders(_state->getContextID(),currentTime,availableTime);
|
||||
osg::RenderBuffer::flushDeletedRenderBuffers(_state->getContextID(),currentTime,availableTime);
|
||||
osg::FrameBufferObject::flushDeletedFrameBufferObjects(_state->getContextID(),currentTime,availableTime);
|
||||
}
|
||||
|
||||
void SceneView::draw()
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <osg/Matrixf>
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Object>
|
||||
#include <osg/State>
|
||||
#include <osg/Texture>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
@ -137,6 +138,7 @@ BEGIN_OBJECT_REFLECTOR(osg::CameraNode)
|
||||
I_Method0(osg::CameraNode::DrawCallback *, getPostDrawCallback);
|
||||
I_Method0(const osg::CameraNode::DrawCallback *, getPostDrawCallback);
|
||||
I_Method0(OpenThreads::Mutex *, getDataChangeMutex);
|
||||
I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, x, 0);
|
||||
I_Method2(bool, computeLocalToWorldMatrix, IN, osg::Matrix &, matrix, IN, osg::NodeVisitor *, x);
|
||||
I_Method2(bool, computeWorldToLocalMatrix, IN, osg::Matrix &, matrix, IN, osg::NodeVisitor *, x);
|
||||
I_ReadOnlyProperty(osg::CameraNode::BufferAttachmentMap &, BufferAttachmentMap);
|
||||
|
Loading…
Reference in New Issue
Block a user