Hi,
I have a texture2D, and I want to change its image dynamically. How can I do
it?
I tried:
>
> Create()===>
> osg::ref_ptr<osg::Geode> geode = new osg::Geode;
> geode->addDrawable( osg::createTexturedQuadGeometry(osg::Vec3(),
> osg::Vec3(40.0,0.0,0.0), osg::Vec3(0.0,0.0,40.0)) );
> geode->setDataVariance(osg::Object::DYNAMIC);
> textureLensFlare = new osg::Texture2D;
> textureLensFlare->setImage( im );
> textureLensFlare->setDataVariance(osg::Object::DYNAMIC);
> textureLensFlare->setFilter(osg::Texture::MIN_FILTER,
> osg::Texture::LINEAR_MIPMAP_LINEAR);
> textureLensFlare->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
> textureLensFlare->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP);
> textureLensFlare->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP);
> geode->getOrCreateStateSet()->setTextureAttributeAndModes(0,
> textureLensFlare, osg::StateAttribute::ON );
> geode->getOrCreateStateSet()->setDataVariance(osg::Object::DYNAMIC);
> geode->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
> geode->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
>
> Change==>
> switch (_iCurrentTexture)
> {
> case 1:
> textureLensFlare->setImage(_im1);
> _im1->dirty();
> break;
>
> case 2:
> textureLensFlare->setImage(_im2);
> _im2->dirty();
> break;
>
> case 3:
> textureLensFlare->setImage(_im3);
> _im3->dirty();
> break;
> }
> textureLensFlare->dirtyTextureObject();
>
But it didn't work. I try with ->dirty() , dirtyTextextureObject(),
->setDaraVariance(osg::Object::DYNAMIC), etc... but no success :(
And another question...What about performance of this method? Approximately, I
will change texture twice each second. Is this a good solution, Or is there any
other better?
Thanks!
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59783#59783
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org