Hi,

I have a OSG texture that i have created to display and image in it with the 
trigger being an input to my application.

I can successfully display the image in the texture but the problem arises when 
this image needs to be changed. When the trigger is called the second time my 
previous image is overwritten and all RGB values are spoilt.(Black Blob)

I would like to know if there is a way to remove the previous image in my 
texture before rendering the new image in the same texture at the same 
geometric coordinates.

Once i have added the drawable to my osg::Group is there a way to still access 
my texture individually?

osg::Image* sym = new osg::Image(); 
                
// This image is changed constantly at a trigger event 
sym->setImage(img.width(),
                      img.height(),
                      1,
                      4,
                      GL_RGBA,
                      GL_UNSIGNED_BYTE,
                      data,
                      osg::Image::USE_NEW_DELETE,
                      1); 
sym->flipVertical();

osg::Geode* pyramidGeode = new osg::Geode();
osg::ref_ptr<osg::Group> roadSign;

float imageWidth = img.width();
float imageHeight = img.height();

osg::ref_ptr<osg::Geometry> pictureQuad1 = 
osg::createTexturedQuadGeometry(osg::Vec3(0, -14, 3),
                                                                                
  osg::Vec3(0,-10, 0),
osg::Vec3(0,0, 10),
                                                                                
      0,
                                                                                
      1,
                                                                                
      1,
                                                                                
      0); 


osg::ref_ptr<osg::Geometry> pictureQuad2 = 
osg::createTexturedQuadGeometry(osg::Vec3(0, 24, 3),
                                                                                
       osg::Vec3(0,-10, 0),
osg::Vec3(0,0, 10),
                                                                                
      0,
                                                                                
      1,
                                                                                
      1,
                                                                                
      0); 


pyramidGeode->addDrawable(pictureQuad1);
pyramidGeode->addDrawable(pictureQuad2);
                
osg::Texture2D* texture = new osg::Texture2D;
texture->setDataVariance(osg::Object::DYNAMIC);
texture->setImage(sym);
                 
osg::StateSet* stateOne = new osg::StateSet();
    stateOne->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
pyramidGeode->setStateSet(stateOne);
roadSign->addChild(pyramidGeode);

Thank you!

Cheers,
Arjun

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=57966#57966





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to