Added calling of releaseGLObjects() and resizeGLObjects() to the Camera DrawCallback's to enable the draw callbacks to clean up their own GL objects.
This commit is contained in:
parent
2e68db5b55
commit
6455159757
@ -614,6 +614,23 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
|||||||
|
|
||||||
/** Functor method, provided for backwards compatibility, called by operator() (osg::RenderInfo& renderInfo) method.**/
|
/** Functor method, provided for backwards compatibility, called by operator() (osg::RenderInfo& renderInfo) method.**/
|
||||||
virtual void operator () (const osg::Camera& /*camera*/) const {}
|
virtual void operator () (const osg::Camera& /*camera*/) const {}
|
||||||
|
|
||||||
|
/** Resize any per context GLObject buffers to specified size. */
|
||||||
|
virtual void resizeGLObjectBuffers(unsigned int maxSize)
|
||||||
|
{
|
||||||
|
if (_nestedCallback.valid())
|
||||||
|
_nestedCallback->resizeGLObjectBuffers(maxSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 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* state = 0) const
|
||||||
|
{
|
||||||
|
if (_nestedCallback.valid())
|
||||||
|
_nestedCallback->releaseGLObjects(state);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Set the initial draw callback for custom operations to be done before the drawing of the camera's subgraph and pre render stages.*/
|
/** Set the initial draw callback for custom operations to be done before the drawing of the camera's subgraph and pre render stages.*/
|
||||||
|
@ -330,25 +330,26 @@ void Camera::detach(BufferComponent buffer)
|
|||||||
|
|
||||||
void Camera::resizeGLObjectBuffers(unsigned int maxSize)
|
void Camera::resizeGLObjectBuffers(unsigned int maxSize)
|
||||||
{
|
{
|
||||||
if (_renderingCache.valid())
|
if (_renderer.valid()) _renderer->resizeGLObjectBuffers(maxSize);
|
||||||
{
|
if (_renderingCache.valid()) _renderingCache->resizeGLObjectBuffers(maxSize);
|
||||||
const_cast<Camera*>(this)->_renderingCache->resizeGLObjectBuffers(maxSize);
|
|
||||||
}
|
if (_initialDrawCallback.valid()) _initialDrawCallback->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_preDrawCallback.valid()) _preDrawCallback->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_postDrawCallback.valid()) _postDrawCallback->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_finalDrawCallback.valid()) _finalDrawCallback->resizeGLObjectBuffers(maxSize);
|
||||||
|
|
||||||
Transform::resizeGLObjectBuffers(maxSize);
|
Transform::resizeGLObjectBuffers(maxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::releaseGLObjects(osg::State* state) const
|
void Camera::releaseGLObjects(osg::State* state) const
|
||||||
{
|
{
|
||||||
if (_renderer.valid())
|
if (_renderer.valid()) _renderer->releaseGLObjects(state);
|
||||||
{
|
if (_renderingCache.valid()) _renderingCache->releaseGLObjects(state);
|
||||||
_renderer->releaseGLObjects(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_renderingCache.valid())
|
if (_initialDrawCallback.valid()) _initialDrawCallback->releaseGLObjects(state);
|
||||||
{
|
if (_preDrawCallback.valid()) _preDrawCallback->releaseGLObjects(state);
|
||||||
_renderingCache->releaseGLObjects(state);
|
if (_postDrawCallback.valid()) _postDrawCallback->releaseGLObjects(state);
|
||||||
}
|
if (_finalDrawCallback.valid()) _finalDrawCallback->releaseGLObjects(state);
|
||||||
|
|
||||||
Transform::releaseGLObjects(state);
|
Transform::releaseGLObjects(state);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user