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

Reply via email to