[osg-users] Allocating osg::image from my own data buffer

Robert Osfield robert.osfield at gmail.com
Mon Aug 22 23:58:25 PDT 2016


HI Bruno,

Simply clone the image i.e.

  osg::ref_ptr<osg::Image> iimag_copy = osg::clone(img);

The osg::Image will copy the internal image data without attempting to
share it, and will own it's own local copy of the data and delete it
automatically when img_copy is deleted (ref count goes to 0.)

Robert


On 22 August 2016 at 21:46, Bruno Oliveira
<bruno.manata.oliveira at gmail.com> wrote:
> Hello,
>
> the following code block is creating an image from a buffer I own. This does
> not allocate a new buffer, but assumes my buffer will not be deallocated.
> How do I create a new, independent osg::Image copying data from my buffer to
> an internal array?
>
> osg::Image img = osg::image();
> img->setImage(
>   width,
>   height,
>   1,
>   internalTextureFormat(),
>   type(),
>   MyDataBuffer(),
>   osg::Image::NO_DELETE);
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



More information about the osg-users mailing list