Hi Fabrizo,

You seem to be a little confused about what you are trying to do and how,
you are over complicating things massively and making a buggy program in
the process.

First up you almost never need to call ref() and unref() directly within an
OSG application, use of ref_ptr<> does this all for your robustly.  By
adding the ref() to the code you have effectly introduced a memory leak as
the Image will never get deleted as it's ref count won't ever get to zero.

All you need to do in your application is do texture->setImage(mynextImage)
and that's it.  No need for any copying of images, just assign the image
and job done, end of story.


Robert.




On 29 August 2014 15:56, Fabrizio Bazzurri <[email protected]> wrote:

> Stephan, Robert,
>
> thank you, I understand. I change this:
>
> Code:
>
> diffuseImage = osgDB::readImageFile(".\\img1.jpg");
> diffuseImage->dirty();
>
>
>
>
> into this:
>
> Code:
>
> osg::ref_ptr<osg::Image> diffuseImage1 =
> osgDB::readImageFile(".\\img1.jpg");
> diffuseImage->setImage(diffuseImage1->s(), diffuseImage1->t(),
> diffuseImage1->r(), diffuseImage1->getInternalTextureFormat(),
> diffuseImage1->getPixelFormat(), diffuseImage1->getDataType(),
> diffuseImage1->data(), diffuseImage1->getAllocationMode());
> diffuseImage->dirty();
> diffuseImage1->ref();
>
>
>
>
> and it works! I don't understand if diffuseImage1->ref() is a good choice
> but without it when I close the program a memory issue arises.
>
> Cheers,
> Fabrizio
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=60855#60855
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to