Thanks, but no dice

On 5/3/07, Michael Henheffer <[EMAIL PROTECTED]> wrote:

Hi Rick,

I'm not sure if this will fix your problem but try calling dirty() on
the image after you modify the data.

Mike

[EMAIL PROTECTED] wrote:
>
> Hello All,
>
>
>
> I am stuck trying to work out how to programmatically create an image
> for a texture.
>
> Here is what I have so far:
>
>
>
> osg::ref_ptr<osg::Image> image = new osg::Image();
> int s, t; s=t=256;
> image->allocateImage(s, t, 1, GL_BGRA, GL_UNSIGNED_BYTE);
>
> for (int row = 0; row < t; ++row)
> {
>  for (int col = 0; col < s; ++col)
>  {
>   unsigned char* newImageData = image->data(col, row);
>   newImageData[0] = row;
>   newImageData[1] = col;
>   newImageData[2] = (row+col)/2;
>   newImageData[3] = 255 - b;
>  }
> }
>
> // It does not seem to work if I do not write the image out and read
> it back in
> osgDB::writeImageFile(*image, "temp.bmp");
> image = osgDB::readImageFile("temp.bmp");
>
> osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
> texture->setImage(image.get());
> ...
>
>
>
> In this code, I am writing the image to a temp file and then reading
> it backout again.  It seems that if I do not do this, it does not
> work.  I am guessing I am not creating the image properly, but the
> .bmp writer is smart enough to figure it out whereas the Texture2D
> does not like it.  I tried looking at the more verbose output and did
> not see anything different.  I wrote both files out to a .osg file,
> but they were identical (neither showing a texture.  Where are
> textures stored when writing osg files anyway?)
>
> This is actually all in my effort to get the osgDB_lwo reader using
> the transparency map from the .lwo file itself.  <I did not imagine I
> would have such a tough time of it :( >.  Even by writing the .bmp out
> and reading it back in, I am not getting the alpha channel for the
> blending.  I have tried allocating the image with "GL_BGR", with no
> more success.
>
> Like I said, I am sure I am doing something wrong.  someone please
> help :O  Perhaps there are examples somewhere of manually creating an
> image as a texture?
>
> You graveling servant
>
> -- Rick
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to