Hi Paulo,

Thanks for the extra explanation. I have just done another code review and
think that it could be the lack of a dirty() call in the Image::setData()
method that is leading to discrepancy.  I have added this to Image.cpp and
checked it into svn/trunk.  The new Image::setData() looks like:

void Image::setData(unsigned char* data, AllocationMode mode)
{
    deallocateData();
    _data = data;
    _allocationMode = mode;
    dirty();
}

Could you try this out?

Robert.

On 18 July 2013 16:57, Paulo Silva <[email protected]> wrote:

> Hi Robert,
>
> well I didn't run the code in debug mode because that would require me to
> recompile osg in debug, and I thought since no one else seems to be
> complaining maybe, as you say, it's something on my part.
>
> Now, as I understand it, cloning an image should be an straightforward
> operation.
> But for some reason I'm getting different results using
>
> Image* a = osgDB::readImageFile("a.png");
>
> tex->setImage(a); // shows image "a.png" on screen
>
> ...
>
> Image* b = osgDB::readImageFile("b.png");
>
> Image* new_image = dynamic_cast<Image*>(b->clone(CopyOp::DEEP_COPY_ALL));
>
> tex->setImage(new_image); // still shows image "a.png"
>
> ...
>
> Image* c = new Image;
>
> c->allocateImage(b->s(), b->t(), b->r(), b->getPixelFormat(), 
> b->getDataType());
>
> memcpy(c->data(), b->data(), b->getTotalSizeInBytes());
>
> tex->setImage(c); // now displays "b.png" correctly
>
> Now, I wonder what could be wrong in that usage of clone. I guess it could
> be the lack of a call to dirty() as you have in allocateImage, but I think
> I tried to add that after the clone and if I remember correctly it made no
> difference.
>
> As far as I am concerned, since I have one method working I'll skip the
> debugging for now.
>
> What I can say is that maybe the clone/copy constructor should be
> implemented in terms of allocateImage.
> Code duplication only leeds to maintenance problems down the road.
>
> Thanks,
> Paulo
>
> _______________________________________________
> 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