Discussion:
non-solid texture color and osg::Image.setImage
Sergey Alekseev
2011-06-22 06:17:48 UTC
Permalink
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
J.P. Delport
2011-06-22 07:20:59 UTC
Permalink
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
Post by Sergey Alekseev
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
------------------
http://forum.openscenegraph.org/viewtopic.php?p=40728#40728
_______________________________________________
osg-users mailing list
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.
Sergey Alekseev
2011-06-22 09:29:33 UTC
Permalink
Hi, JP,

thanks you for your answer.

I have made as you wrote and have received - the same solid texture color. Only has changed color of a texture: from dark lila to dark grey.


thank you,
sergey

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=40738#40738
J.P. Delport
2011-06-22 13:33:32 UTC
Permalink
Hi,
Post by Sergey Alekseev
Hi, JP,
thanks you for your answer.
I have made as you wrote and have received - the same solid texture color. Only has changed color of a texture: from dark lila to dark grey.
how are you applying the texture to geometry? Are your texture
coordinates OK?

jp
Post by Sergey Alekseev
thank you,
sergey
------------------
http://forum.openscenegraph.org/viewtopic.php?p=40738#40738
_______________________________________________
osg-users mailing list
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.
Loading...