Added releaseGLObjects(State*) support into osg::FrameBufferObject, osg::RenderBin and osg::RenderStage

to ensure proper clean up of FBO's on closing a graphics context.
This commit is contained in:
Robert Osfield
2011-04-20 11:45:01 +00:00
parent f564926570
commit 70aa087f6e
8 changed files with 158 additions and 2 deletions

View File

@@ -284,6 +284,36 @@ GLuint RenderBuffer::getObjectID(unsigned int contextID, const FBOExtensions *ex
return objectID;
}
void RenderBuffer::resizeGLObjectBuffers(unsigned int maxSize)
{
_objectID.resize(maxSize);
_dirty.resize(maxSize);
}
void RenderBuffer::releaseGLObjects(osg::State* state) const
{
if (state)
{
unsigned int contextID = state->getContextID();
if (_objectID[contextID])
{
deleteRenderBuffer(contextID, _objectID[contextID]);
_objectID[contextID] = 0;
}
}
else
{
for(unsigned i=0; i<_objectID.size(); ++i)
{
if (_objectID[i])
{
deleteRenderBuffer(i, _objectID[i]);
_objectID[i] = 0;
}
}
}
}
/**************************************************************************
* FrameBufferAttachment
**************************************************************************/
@@ -748,6 +778,37 @@ FrameBufferObject::~FrameBufferObject()
}
}
void FrameBufferObject::resizeGLObjectBuffers(unsigned int maxSize)
{
_fboID.resize(maxSize);
_unsupported.resize(maxSize);
_fboID.resize(maxSize);
}
void FrameBufferObject::releaseGLObjects(osg::State* state) const
{
if (state)
{
unsigned int contextID = state->getContextID();
if (_fboID[contextID])
{
deleteFrameBufferObject(contextID, _fboID[contextID]);
_fboID[contextID] = 0;
}
}
else
{
for(unsigned int i=0; i<_fboID.size(); ++i)
{
if (_fboID[i])
{
deleteFrameBufferObject(i, _fboID[i]);
_fboID[i] = 0;
}
}
}
}
void FrameBufferObject::setAttachment(BufferComponent attachment_point, const FrameBufferAttachment &attachment)
{
_attachments[attachment_point] = attachment;