I've done something similar using setImage that should work for what you
are doing. I do something like this:
int s, t; s=t=256;
unsigned char * rgbaData = new unsigned char [s*t*4];
//populate the image data, in this case in rgba format.
osg::ref_ptr<osg::Image> pImage = new osg::Image();
pImage->setImage(s,t,1,4,GL_RGBA,GL_UNSIGNED_BYTE,rgbaData,osg::Image::USE_NEW_DELETE);
The fourth parameter is the internal texture format. That's the only
thing I could see differing from what you are doing. It can also be set
with
void setInternalTextureFormat
<http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/classosg_1_1Image.html#a22>
(GLint internalFormat)
I hope this helps a little more.
Mike
[EMAIL PROTECTED] wrote:
Thanks, but no dice
On 5/3/07, *Michael Henheffer* <[EMAIL PROTECTED]
<mailto:[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] <mailto:[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] <mailto:[email protected]>
> http://openscenegraph.net/mailman/listinfo/osg-users
<http://openscenegraph.net/mailman/listinfo/osg-users>
> http://www.openscenegraph.org/
_______________________________________________
osg-users mailing list
[email protected] <mailto:[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/
--
CARIS
115 Waggoners Lane, Fredericton, New Brunswick, Canada, E3B 2L4
Tel: +1-506-458-8533 Fax: +1-506-459-3849
_________________________________________________________________________
New Viewer for 2D and 3D Data
Download your free copy of CARIS Easy View today!
www.caris.com/easyview
_________________________________________________________________________
This email and any files transmitted with it are confidential and
intended only for the addressee(s). If you are not the intended
recipient(s) please notify us by email reply. You should not use,
disclose, distribute or copy this communication if received in error.
Any views or opinions expressed in this email are solely those of the
author and do not necessarily represent those of the company. No binding
contract will result from this email until such time as a written
document is signed on behalf of the company.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/