Thanks David! I got it to work now. 

Here my function creating a 2D texture from a 2-Dimensional vector, in case 
it's of any use to anyone. 


Code:

osg::Texture2D* createTextureLUT2D(std::vector<std::vector<float> >& data)
{
        int rows = data.size();
        int cols = data[0].size();
        
        //create image containing one channel of float, we use the RED channel
        osg::Image* image = new osg::Image;
        image->allocateImage(cols, rows, 1, GL_RED, GL_FLOAT);
        image->setInternalTextureFormat(GL_R32F);       

        //set the data to the image; the image stores successive columns rather 
than succesive rows
        float* dataPtr = (float*)image->data();
        for (int b = 0; b < cols; b++)
                for (int a = 0; a < rows; a++)
                        *dataPtr++  = data[a][b];

        //create the texture and set its image
        osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
        texture->setImage(image);
        texture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::NEAREST);
        texture->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST);

        return texture.release();
}




cheers, Ivar

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74963#74963





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to