Hello Per,

> I too need to show images. Since osg is (and should be) 3d-based, the 
> way to do is seemed to be to display a rectange Geometry infront of an 
> orthographic camera, and set the rectangle texture to be the image.

To that end, there is a utility function in the Geometry header.

#include <osg/Geometry>

osg::Geode* createNodeWithMyImageOnIt(const std::string& filename)
{
     osg::Geode* geode = new osg::Geode;
     osg::Geometry* geometry =
         osg::createTexturedQuadGeometry(osg::Vec3(0,0,0),
                                         osg::Vec3(1,0,0),
                                         osg::Vec3(0,0,1),
                                         0, 0, 1, 1);
     geode->addDrawable(geometry);
     osg::Texture2D* texture =
         new osg::Texture2D(osgDB::readImageFile(filename));
     geode->getOrCreateStateSet()->setTextureAttributeAndModes(0,
         texture, osg::StateAttribute::ON);
     geode->getOrCreateStateSet()->setTextureMode(0, GL_TEXTURE_2D,
         osg::StateAttribute::ON);

     return geode;
}

Note this is off the top of my head, untested, possibly incomplete. But 
it should give you an idea. Look up the doxygen for 
osg::createTexturedQuadGeometry for details.

Hope this helps,

J-S
-- 
______________________________________________________
Jean-Sebastien Guay    [EMAIL PROTECTED]
                                http://www.cm-labs.com/
                         http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to