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
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to