[osg-users] Strange setImage behaviour

David Spilling david.spilling at gmail.com
Tue Mar 10 10:26:21 PDT 2009


Max,

For starters, you probably want GL_RGB8 (0x8051) and not GL_TEXTURE_2D
(0x0DE1) in your setImage call.

But in general it looks a bit odd to me, and I'm not sure what your
intention was. First you get the pointer to the textures image, and then you
set it to something else. I imagine you just need to do something like:

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 = osgDB::readImageFile("test.jpg");
       Tex->setImage(teximg.get());
       return;
}

with some appropriate dirtying (although this assumes that Tex is non null,
so you might want to have some of your previous code to actually set up the
texture if it is null).

Hope that helps,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20090310/773b16e3/attachment-0003.htm>


More information about the osg-users mailing list