Hi Brett,

The Viewer does it best to deallocate and clean up all buffers on the
scene graphs that it knows about, but your code is hidding the scene
graph from it by removing them from the view's scene graph so these
removed elements do go throw the OpenGL clean up process.

If you really want to use the OSG in this kack handed way then call
releaseGLObjects() on the subgraph that you've detacthed.

You example code was pretty ropey - it's not an app in its own right
so one had covert it into a application, and then because of adding of
adding of the scene graph after realize and that no home was recent
the viewer's camera wasn't pointed at the scene graph, so one could
verify anything.  In future could you please provide example codes
that can be run as-as, and ones that you can actually see something.

Robert.

On Fri, Nov 21, 2008 at 4:49 PM, brettwiesner <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a simple example that shows that if you run a viewer, tear it down
> and run it again, textures are missing. (winXP, 2.6.0). It appears that
> resources such as Textures and DisplayLists are leaking and corrupting runs.
>
> The attached example simply creates a viewer and loads the cow.osg file.
> Press "esc" to exit the viewer which removes the cow from the scene and
> tears the viewer down. Then another viewer is created and the cow is loaded
> again. This time, the cow has no textures.
>
> What calls are necessary to properly deallocate resources when tearing down
> the viewer so that future viewers can be created and load the next
> resources?
>
> Thanks,
> Brett
>
>
> #include <osg/ref_ptr>
> #include <osgDB/ReadFile>
> #include <osgViewer/Viewer>
> #include <osgGA/TrackballManipulator>
> #include <osgDB/ReadFile>
> #include <osgDB/WriteFile>
>
> void testViewerTeardown()
> {
>        {
>                osg::ref_ptr<osgViewer::Viewer> viewer = new
> osgViewer::Viewer;
>                osg::ref_ptr<osg::Group> root = new osg::Group;
>                viewer->setUpViewOnSingleScreen(0);
>                viewer->setSceneData(root.get());
>                viewer->setCameraManipulator(new
> osgGA::TrackballManipulator());
>                viewer->realize();
>                {
>                        std::string originalFile = "Cow.osg";
>                        osg::ref_ptr<osgDB::ReaderWriter::Options> options =
> osgDB::Registry::instance()->getOptions();
>                        osg::ref_ptr<osg::Node> modelNode =
> osgDB::readNodeFile(originalFile, options.get());
>                        root->addChild(modelNode.get());
>                        viewer->run();
>                        root->removeChildren(0,root->getNumChildren());
>                }
>        }
>
>        {
>                osg::ref_ptr<osgViewer::Viewer> viewer = new
> osgViewer::Viewer;
>                osg::ref_ptr<osg::Group> root = new osg::Group;
>                viewer->setUpViewOnSingleScreen(0);
>                viewer->setSceneData(root.get());
>                viewer->setCameraManipulator(new
> osgGA::TrackballManipulator());
>                viewer->realize();
>                {
>                        std::string originalFile = "Cow.osg";
>                        osg::ref_ptr<osgDB::ReaderWriter::Options> options =
> osgDB::Registry::instance()->getOptions();
>                        osg::ref_ptr<osg::Node> modelNode =
> osgDB::readNodeFile(originalFile, options.get());
>                        root->addChild(modelNode.get());
>                        viewer->run();
>                        root->removeChildren(0,root->getNumChildren());
>                }
>        }
> }
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to