Hi Divik,

m_loadedModel = 0

Is all you need, the ref_ptr<> and osg::Referened will do all the
clean up for you.  If the global ref_ptr<> goes out of scope it'll
also automatically delete things.

The only thing that won't get deleted and OpenGL objects that the
scene graph is associated with.  The OSG can't delete these
automatically as you can only delete OpenGL from the thread that has
each of the contexts current, instead it puts the OpenGL objects in
lists ready to be properly deleted.  There is a helper function in
osgUtil::SceneView for flush all deleted OpenGL objects.

Robert.

On 7/5/06, Divick Kishore <[EMAIL PROTECTED]> wrote:

 Hi all,
           what is the correct way to delete objects from heap in
openscenegraph ? Since all destructors are protected for all classes derived
from Referenced, so I cannot delete the objects created on heap and nor can
I create object on stack. Thus the only way is to create using new and
assign in a ref_ptr.
     Now the problem is if I have already something inside the ref_ptr and I
want to put something else in it then how shall I tell ref_ptr to delete it?
AFAIK, one should not use the release method of ref_ptr to delete the
object. So what option am I left with?

 To be more precise in the code below I am loading a scenegraph from a file
and the point to it by a ref_ptr m_loadedModel. Now assume that I already
have a scenegraph loaded , then isn't it I need to unload or delete the
scenegraph that is already loaded?

 osg::ref_ptr<osg::Node>  m_loadedModel;

 //Shouldn't I delete the scenegraph if it is already loaded in the
m_loadedModel ???
 m_loadedModel = osgDB::readNodeFile(fileName.c_str());

 Hope my question is clear,
 Thanks for reply,
 Divick

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to