Hi Kedar,

On 28/06/12 19:10 , Kedar Kumbhar wrote:
> The normal method given in many examples to create a Texture2D, is using a 
> Image file.
> 
> Code:
> osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
>       osg::ref_ptr<osg::Image> image = osgDB::readImageFile("Images/lz.rgb" );
>       texture->setImage( image.get() );
> 
> Instead, I have a osg::Vect4Array in which I have color information (rgba).
> 
> How can I use this Vec4Array to create Texture2D?

Vec4Array is-a std::vector and contains a contiguous block of its base type, 
such as
float.  I haven't tested this, but you should be able to just call:

osg::Image::setImage(
        width, height, 1,
        GL_RGBA8,
        GL_RGBA, GL_FLOAT,
        (unsigned char*) &vec4Array[0], NO_DELETE);

Hope this helps,
Cheers,
/ulrich
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to