Hello,
Can you please correct any wrong statements:
1. osg::ref_ptr increments the reference count when it is constructed
with a pointer.
2. osg::ref_ptr decrements the reference count when it is destroyed
3. osg::ref_ptr::get returns a raw pointer and does not increase the
reference count
4. when the reference count becomes zero, the underlying object is deleted
5. The following code appears in the osgscreencapture example (minus
some unrelated content):
if (pbuffer.valid())
{
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
camera->setGraphicsContext(pbuffer.get());
camera->setViewport(new osg::Viewport(0,0,width,height));
GLenum buffer = pbuffer->getTraits()->doubleBuffer ? GL_BACK : GL_FRONT;
camera->setDrawBuffer(buffer);
camera->setReadBuffer(buffer);
camera->setFinalDrawCallback(new WindowCaptureCallback(mode,
position, readBuffer));
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
viewer.realize();
}
6. The reference count of "camera" is incremented when it is constructed
7. The raw osg::Camera* is passed to viewer.addSlave, which does not
increment the reference count.
8. The osg::ref_ptr is not passed to anything
9. The reference count is not incremented anywhere else other than
during construction.
7. The reference count of "camera" is decremented when it reaches the
end of the if-block.
8. The reference count becomes zero at the end of the if-block
9. The camera object is destroyed at the end of the if-block
10. The raw camera pointer passed to viewer.addSlave is now invalid
11. The program should crash as soon as the viewer or anybody else
does anything with the camera
Thank you,
Chris
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org