Sergey Alekseev
2011-06-22 06:17:48 UTC
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::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