[osg-users] Strange setImage behaviour
osgforum at tevs.eu
Tue Mar 10 10:06:36 PDT 2009
First, I'm sorry to disturb all of you with such a dumb question.
I have a strange problem with osg::Image::setImage.
I use both osg and opencv and I want to convert an opencv image into an osg.
It's in order to update a texture, here's my code:
void updateTexture( IplImage *img, ref_ptr<Node> geode)
ref_ptr<StateSet> state = geode->getOrCreateStateSet();
ref_ptr<Texture2D> Tex = (Texture2D*) state->getTextureAttribute(0,StateAttribute::TEXTURE);
ref_ptr<Image> teximg = Tex->getImage();
//teximg = osgDB::readImageFile("test.jpg");
GL_UNSIGNED_BYTE, (unsigned char*) img->imageData,
I wonder if I shouldn't put a
teximg->allocateImage(img->width, img->height, 1,
because I already have an image I just update it. But with or without it , I have the same problem.
The strange thing is it worked well yesterday, and I don't know why it doesn't anymore today, and as I work alone, I don't use any svn to get back an older version...
When I un-comment the commented line, it works fine (but it's not my aim), thus the problem is in set Image, which I'm sure I didn't modify.
I really don't see where it comes from!
Thanks for reading me (and more if you reply).
Read this topic online here:
More information about the osg-users