Hi. I need to use an buffer to update a texture. I can do it but the bad point is that my item is a full collored Quad and not an image. The color is the first color of my buffer.
i can change every things but not the buffer, i receive it as a <unsigned char*> and i know the width and the height. Is it RGB mode, no alpha. Could you help me? thanks you a lot ! This is my code to create items: Code: //objets from my class osg::Texture2D* texture_; //Constructor osg::Image* im = new osg::Image; im->allocateImage(1024 , 1024, 1 , GL_RGB, GL_UNSIGNED_BYTE); texture_ = new osg::Texture2D; texture_->setDataVariance(osg::Object::DYNAMIC); texture_->setImage(im); osg::ref_ptr<osg::Vec3Array> vertex_ = new osg::Vec3Array; osg::Geometry * g = new osg::Geometry; g->setVertexArray( vertex_.get() ); float x = 512; static float zFar = -10000; vertex_->push_back( osg::Vec3( -x , -x , zFar ) ); vertex_->push_back( osg::Vec3( x , -x , zFar ) ); vertex_->push_back( osg::Vec3( x , x , zFar ) ); vertex_->push_back( osg::Vec3( -x , x , zFar ) ); g->addPrimitiveSet(new osg::DrawArrays( osg::PrimitiveSet::QUADS, 0, 4 ) ); stateset_ = g->getOrCreateStateSet(); stateset_->setTextureAttributeAndModes(0, texture_, osg::StateAttribute::ON); stateset_->setMode(GL_BLEND,osg::StateAttribute::ON); stateset_->setRenderingHint(osg::StateSet::OPAQUE_BIN); osg::Geode* geode = new osg::Geode; geode->addDrawable(g); texture_->setImage(im); This is my code to update texture: (simplified) Code: void Background::majTexture(unsigned char* newValue) { memcpy(texture_->getImage()->data(), newValue, 1024 * 1024 * 3); //1024 * 1024 * 3 = height * weight * number of composant for one pixel } ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=27008#27008 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org