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
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to