[osg-users] release and flush GL Objects?

Robert Osfield robert.osfield at gmail.com
Mon Sep 17 09:26:55 PDT 2007


HI Rafa,

On 9/17/07, Rafa Gaitan <rafa.gaitan at gmail.com> wrote:
> Node doesn't have a releaseAllGLObjects, and trying with
> releaseGLObjects, doesn't work as I expect. Maybe I'm using
> a bad approach to the problem! :(.

Sorry,

  viewer->releaseGLObjects();

Is the call I was thinking of.

> releaseAllGLObjects method is only inside SceneView class
> which is not easily accessible in the osgViewer::Viewer.

You get get the SceneView via the Renderer object which is attached
the Camera in 2.1.x.

However, you shouldn't need it.

All SceneView::releaseAllGLobjects() does is:

void SceneView::releaseAllGLObjects()
{
    if (!_camera) return;

    _camera->releaseGLObjects(_renderInfo.getState());

    // we need to reset State as it keeps handles to Program objects.
    if (_renderInfo.getState()) _renderInfo.getState()->reset();
}

And all SceneView::flushAllDeletedGLObjects() does is:

void SceneView::flushAllDeletedGLObjects()
{
    _requiresFlush = false;

    osg::flushAllDeletedGLObjects(getState()->getContextID());
}

So you could try:

viewer.getSceneData()->releaseGLObjects(); // or getCamera()...
viewer.getCamera()->getGraphicsContext()->getState()->reset();
osg::flushAllDeletedGLObjects(0);



More information about the osg-users mailing list