Hello,
I am working on converting a project from SGI Performer in C
to OSG, so I am familiar with constructing a scene graph.
For this project I load all the models I plan to use into a
data structure, at a later point in time based on the user
responses I swap out the sub-graphs that I wish displayed.
The problem is the memory manager ends up freeing my nodes.
I know the OSG answer will be to add a switch node as the
parent of each of the sub graphs then toggle those on and
off.
Is there a way to tell OSG that I will let it know when I'm
done with a node?
What should happen in this example snippet is loading two
models which are get swapped in/out by the user pressing "1"
or "2".
What ends up happening is the program crashes the 2nd time I
tried to load either model.
Setup in pseudo code based on the Glut example code is
something like ...
osg::ref_ptr<osg::Node> pNode1;
osg::ref_ptr<osg::Node> pNode2;
void keyboard( unsigned char key, int /*x*/, int /*y*/ )
{
switch( key )
{
case '1':
viewer->setSceneData( pNode1 );
break;
case '2':
viewer->setSceneData( pNode2 );
break;
// other cases
}
}
main()
{
// some initilization ...
pNode1 = osgDB::readNodeFiles(File1);
pNode2 = osgDB::readNodeFiles(File2);
// more initilization
viewer->setSceneData( pNode1 );
viewer->realize();
glutMainLoop();
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org