Hello everybody,
I opened another thread because the other one was getting a little big ;)
Here's the problem : it's still related to what I explained in my old posts : I
set the data of an image by hand, using getData to get the memory pointer of
the data, and then setting this pointer to another location (and then calling
imageContentChanged() on the chunk that use this image). Then I want to use
this display this data in a glsl shader (SHLChunk). The image is a 3D image.
The texture is rendered black whereas my data array contains non-black pixels.
So I tried to check what's in the texture by creating png files of each of the
slices of the 3D texture. The number of pixels in width, length and height of
this 3D image are called iBar, jBar, kBar, respectively (I know the texture
should have a power of 2 size but it's not the purpose of this little test
right now : I just want to see what's in the 3D image). Here's a code sample
showing this :
// creating an image which I'll use to write my slices to png files :
ImagePtr saveImg = Image::create();
beginEditCP(saveImg);
saveImg->set( Image::OSG_RGB_PF, iBar, jBar, 1, 1, 1,
0);
endEditCP(saveImg);
// loop over the kBar slices of the data
for(int i=0;i<kBar;i++)
{
// Getting the pointer of the image I want to write
UChar8 *dataImgSave = saveImg->getData();
// setting this pointer to the memory location where the data of the
slice is stored (i*iBar*jBar*3 is equal to the position of the first pixel of
the [i] slice : the "3" is here because the array is an array of UInt8, which
go 3 by 3, for stocking RGB)
dataImgSave = &(pDataArray[i*iBar*jBar*3]);
// display in the console the content of this data array :
for(int ic=0 ; ic < iBar*jBar*3 ; ic = ic + 3)
cout << "pixel (r,g,b): "<<dataImgSave[ic] <<","
<<dataImgSave[ic+1] << ","
<<dataImgSave[ic+2] << "\n";
//setting a name for the png file
std::string chaine("images3D/debugImage_");
std::ostringstream ss;
ss << i;
chaine += ss.str();
chaine += ".png";
// saving the file to disk :
if(saveImg->write(chaine.c_str()))
cout << "write image " << i << " OK \n";
}
That's it. The "cout << ..." shows me that my array is filled with non-zero
values. But the images written to the disk are black!
Is there something wrong in this test, or in the way I set the data to the
image?
Thanks for your help
Jo
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users