I am trying to use a 32 bit RGBA texture to use as a look up table in a shader 
to do color correction. If I setup a texture in the following manner I get 
nothing but a blank image (for my test shader, I am just outputting the color 
of my LUT texture):

m_pLUTImage = new osg::Image();
m_pLUTImage->allocateImage(1600,1200,1,GL_RGBA32F_ARB,GL_FLOAT);
////////
unsigned char* buff = m_pLUTImage->data();

float r =0.0; float g=1.0; float b = 1.0; float a = 1.0f;
for (unsigned int i = 0; i < 1600; i++){
                for (unsigned int j =0; j < 1200; j++){
                                memcpy(&(buff[(i * 1600 + j) * 4+0]  ),  &r,4);
                                memcpy(&(buff[(i * 1600 + j) * 4+4]  ),  &g,4);
                                memcpy(&(buff[(i * 1600 + j) * 4+8]  ),  &b,4);
                                memcpy(&(buff[(i * 1600 + j) * 4+12]), &a,4);
                }
}
m_pLUT = new osg::Texture2D();
m_pLUT->setImage(m_pLUTImage);
m_pLUT->setDataVariance(osg::Object::DYNAMIC);

If I do:
m_pLUTImage->allocateImage(1600,1200,1,GL_RGBA,GL_BYTE);

and I change how I fill the texture to deal with the different types I get what 
I am expecting.

What am I doing wrong here?

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

Reply via email to