are you trying to display an image that has the same size as your screen? If
so, you might want to do it with HUD (have a look at osghud example) and
with TextureRectangle instead ....

-Nick


On Thu, Mar 11, 2010 at 4:29 PM, Akilan Thangamani <
[email protected]> wrote:

> Hi,
>
> Extremely sorry for my first question as I was not reading the image file
> properly, I couldn't get the display as I thought. But regarding my 2nd
> question, I m taking a buffer(filled with image pixels) of size exactly
> equivalent to of  my screen resolution (1280 * 960). I m trying to display
> it in such a way to exactly fit onto my screen without scaling down/up. I
> put my code to show the way I create the texture,
>
> osg::Node* CreateTexImage()
> {
>            osg::BoundingBox bb(0.0f,0.0f,0.0f,1.0f,1.0f,1.0f);
>            osg::Group* group = new osg::Group;
>
>            osg::Vec3 top_left(bb.xMin(),bb.yMin(),bb.zMax());
>            osg::Vec3 bottom_left(bb.xMin(),bb.yMin(),bb.zMin());
>            osg::Vec3 bottom_right(bb.xMin(),bb.yMax(),bb.zMin());
>            osg::Vec3 top_right(bb.xMin(),bb.yMax(),bb.zMax());
>            osg::Vec3
> center(bb.xMin(),(bb.yMin()+bb.yMax())*0.5f,(bb.zMin()+bb.zMax())*0.5f);
>            float height = bb.zMax()-bb.zMin();
>
>            osg::Geometry* geom = new osg::Geometry;
>
>            osg::Vec3Array* vertices = new osg::Vec3Array(4);
>            (*vertices)[0] = top_left;
>            (*vertices)[1] = bottom_left;
>            (*vertices)[2] = bottom_right;
>            (*vertices)[3] = top_right;
>            geom->setVertexArray(vertices);
>
>            osg::Vec2Array* texcoords = new osg::Vec2Array(4);
>            (*texcoords)[0].set(0.0f,1.0f);
>            (*texcoords)[1].set(0.0f,0.0f);
>            (*texcoords)[2].set(1.0f,0.0f);
>            (*texcoords)[3].set(1.0f,1.0f);
>            geom->setTexCoordArray(0,texcoords);
>
>            osg::Vec3Array* normals = new osg::Vec3Array(1);
>            (*normals)[0].set(1.0f,0.0f,0.0f);
>            geom->setNormalArray(normals);
>            geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
>
>            osg::Vec4Array* colors = new osg::Vec4Array(1);
>            (*colors)[0].set(1.0f,1.0f,1.0f,1.0f);
>            geom->setColorArray(colors);
>            geom->setColorBinding(osg::Geometry::BIND_OVERALL);
>
>            geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4));
>
>            osg::Geode* geom_geode = new osg::Geode;
>            geom_geode->addDrawable(geom);
>            group->addChild(geom_geode);
>
>            osg::Texture2D* texture = new osg::Texture2D;
>            texture->setDataVariance(osg::Object::DYNAMIC);
>
>        unsigned char* data;
>        int width, height;
>         width=1280; //source_image width
>        height=960;//source_image height
>         long size = width * height;
>        data = new unsigned char[size];
>
>         //Reading Image of width * height into buffer
>        for(i=0;i<(width * height); i++)
>                data[i]=source_image[i]);
>
>        //Setting image
>        osg::ref_ptr<osg::Image> image = new osg::Image;
>        image->allocateImage(width, height, 1, GL_LUMINANCE,
> GL_UNSIGNED_BYTE);
>         image->setOrigin(osg::Image::BOTTOM_LEFT);
>         image->setImage(width, height, 1, GL_LUMINANCE, GL_LUMINANCE,
> GL_UNSIGNED_BYTE,data, osg::Image::NO_DELETE);
>        texture->setImage(image);
>
>             osg::StateSet* stateset = geom->getOrCreateStateSet();
>
>  stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
>
>            return group;
>
> }
>
> Let me understand what needs to be done to fit onto my screen exaxtly
> without scaling?
>
> Thanks
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=25525#25525
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to