Hi,
I need to continously display incoming images from a network location. Images
are in the form of raw data bits, whose resolution may change. Looking at osg
Movie example i used createTexturedQuadGeometry to create a geometry of size of
first frame. Then rest of incoming images are used as texture on this quad
using osg::TextureRectangle. But since resolution of these images change,
images are not displayed fully on the quad. I even tried to scale the image and
resize the texture, but they did not work.
For example if my quad is of size 1280X1024, and next frame is of 800x600, it's
not displayed on the quad filling the whole quad and occupies only small
region, where rest of region remains empty
Please help...
I am posting my code here:
to create geometry:
geometry =
Code:
osg::createTexturedQuadGeometry(osg::Vec3(0.f,0.f,0.f),osg::Vec3(width,0.0f,0.0f),osg::Vec3(0.0f,0.0f,height),0.0f,height,width,1.0f);
to update texture each time with new image (from frame object):
Code:
class textureCallback: public osg::NodeCallback
{
public:
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osg::ref_ptr<osg::Geode> geode=dynamic_cast<osg::Geode*>(node);
osg::ref_ptr<osg::Image> image = new osg::Image();
image->setImage(frame->crop.width,abs(frame->crop.height),0,GL_RGB,GL_BGR,GL_UNSIGNED_BYTE,(unsigned
char*)frame->pixbuf,osg::Image::AllocationMode::USE_MALLOC_FREE);
osg::ref_ptr<osg::TextureRectangle> myTex= new
osg::TextureRectangle(image.get());
myTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
myTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
myTex->setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_EDGE);
osg::ref_ptr<osg::StateSet> stateone=new osg::StateSet();
stateone->setTextureAttributeAndModes(0,myTex.get(),osg::StateAttribute::ON);
geode->setStateSet(stateone.get());
traverse(node,nv);
}
};
...
Thank you!
Cheers,
Saket
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=28897#28897
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org