Hi James,

Is there a reason the destructor for the Shader object is protected?

Like all classes derived from osg::Referenced, you're not supposed to create them as normal variables. You use ref_ptr and new, like this:

osg::ref_ptr<osg::Shader> shader = new osg::Shader(...);

The destructor of classes derived from osg::Referenced are declared protected to enforce this. There are probably other reasons, but that's the net effect - you need to use new because if not, the compiler will complain that the destructor is protected at the end of the scope; even when you use new you can't delete them manually, so you need ref_ptr to manage the ref count, and the (protected) osg::Referenced destructor will delete the object automatically once the ref count goes to 0.

See include/osg/Referenced line 184 (in current trunk)

http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/include/osg/Referenced#L184

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    [EMAIL PROTECTED]
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to