Hi,
for an RGBA texture you would need data to be of size width*height*4.
Also, not sure what your magic 4 is in image -> setImage. Put GL_RGBA
instead of 4.
Try:
image -> setImage (width, height, 1,
GL_RGBA,
GL_RGBA,
GL_UNSIGNED_BYTE,
data,
osg::Image::NO_DELETE
);
jp
On 22/06/11 08:17, Sergey Alekseev wrote:
I generate a texture as follows:
osg::Texture2D * map ()
{
int width = 38, height = 40;
osg::Texture2D * map = new osg::Texture2D;
map -> setTextureSize (width, height);
map -> setFilter (osg::Texture2D::MIN_FILTER,
osg::Texture2D::LINEAR);
map -> setFilter (osg::Texture2D::MAG_FILTER,
osg::Texture2D::LINEAR);
osg::Image * image = new osg::Image;
unsigned char * data = new unsigned char [width * height];
for ( unsigned y = 0; y< height ; y ++ )
for( unsigned x = 0; x< width; x ++ ) {
int random = rand () % 5000;
data [y * width + x] = (unsigned char) x * y;
}
image -> setImage (width, height,
1,
4,
GL_RGBA,
GL_UNSIGNED_BYTE,
data,
osg::Image::NO_DELETE
);
map -> setImage (image);
return map;
}
However, despite different values the data placed in the osg::Image buffer data
a texture always it is displayed by solid color.
Color changes depending on value of parameters: width, height, 1, 4, GL_RGBA,
GL_UNSIGNED_BYTE,but always stays as solid.
How i can make that each point of a texture was displayed by the color set in
the buffer data?
Where I can read more detailed documentation on osg:: Image.setImage?
thanks,
sergey
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=40728#40728
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org