diff --git a/include/osg/Camera b/include/osg/Camera index fc9671d84..b1cfc95dc 100644 --- a/include/osg/Camera +++ b/include/osg/Camera @@ -599,12 +599,12 @@ class OSG_EXPORT Camera : public Transform, public CullSettings Callback(org, copyop) {} META_Object(osg, DrawCallback); - + /** Functor method called by rendering thread to recursively launch operator() on _nestedcallback **/ inline void run(osg::RenderInfo& renderInfo) const { operator () (renderInfo); - + if (_nestedCallback.valid()) ((const DrawCallback*)_nestedCallback.get())->run(renderInfo); } @@ -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.**/ 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.*/ diff --git a/src/osg/Camera.cpp b/src/osg/Camera.cpp index 1fec7aadc..640efc165 100644 --- a/src/osg/Camera.cpp +++ b/src/osg/Camera.cpp @@ -330,25 +330,26 @@ void Camera::detach(BufferComponent buffer) void Camera::resizeGLObjectBuffers(unsigned int maxSize) { - if (_renderingCache.valid()) - { - const_cast(this)->_renderingCache->resizeGLObjectBuffers(maxSize); - } + if (_renderer.valid()) _renderer->resizeGLObjectBuffers(maxSize); + if (_renderingCache.valid()) _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); } void Camera::releaseGLObjects(osg::State* state) const { - if (_renderer.valid()) - { - _renderer->releaseGLObjects(state); - } + if (_renderer.valid()) _renderer->releaseGLObjects(state); + if (_renderingCache.valid()) _renderingCache->releaseGLObjects(state); - if (_renderingCache.valid()) - { - _renderingCache->releaseGLObjects(state); - } + if (_initialDrawCallback.valid()) _initialDrawCallback->releaseGLObjects(state); + if (_preDrawCallback.valid()) _preDrawCallback->releaseGLObjects(state); + if (_postDrawCallback.valid()) _postDrawCallback->releaseGLObjects(state); + if (_finalDrawCallback.valid()) _finalDrawCallback->releaseGLObjects(state); Transform::releaseGLObjects(state); }