Hello Laurens, Thank you, you are correct it worked.
Best regards, On Fri, Oct 15, 2010 at 11:23 AM, Laurens Voerman <[email protected]> wrote: > Hi Mahendra , > osgimage::data() returns an (unsigned char *) so the array indexing only > steps one byte. use > > ((float *)dirImage->data(i))[0] = pos.x();//same effect > ((float *)dirImage->data(i))[1] = pos.y();//different effect > ((float *)dirImage->data(i))[2] = pos.z(); > > Laurens. > > > On 10/15/2010 10:55 AM, Mahendra G.R wrote: > >> Hello guys, >> >> I'm trying to write and then read back float data from an image but for >> some reason only the last written data seems correct >> >> >> code: >> >> dirImage->allocateImage((int) vertices.size(), (int)vertices.size(), >> (int)vertices.size(), GL_RGB, GL_FLOAT); >> >> for ( unsigned int i = 0; i < vertices.size(); i++) >> { >> osg::Vec3 pos = vertices[i]; >> (float &)dirImage->data(i)[0] = pos.x(); >> (float &)dirImage->data(i)[1] = pos.y(); >> (float &)dirImage->data(i)[2] = pos.z(); >> >> std::cout<<"actual.x is"<<pos.x()<<std::endl; >> std::cout<<"actual.y is"<<pos.y()<<std::endl; >> std::cout<<"actual.z is"<<pos.z()<<std::endl; >> >> std::cout<<"pos.x is"<<(float &)dirImage->data(i)[0]<<std::endl; >> std::cout<<"pos.y is"<<(float &)dirImage->data(i)[1]<<std::endl; >> std::cout<<"pos.z is"<<(float &)dirImage->data(i)[2]<<std::endl; >> >> >> } >> >> can anybody point out the mistake, sorry if its too silly. >> >> -- >> http://www.mahendragr.com >> >> >> >> _______________________________________________ >> 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 > -- http://www.mahendragr.com
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

