Hi Art,
I took a look into the UnitOutCapture.cpp file. It uses the
Image::readImageFromCurrentTexture function. I assume it reads the entire
texture back to system-memory. I may be able to use that... But, I assume that
if I send a compressed texture to video-memory, then I will get a compressed
texture back. The Image::getColor function does not support compressed textures.
I have written a node-visitor that prevents OSG from deleting the Image
pointers of textures in node-files that my application reads, so I have solved
my problem as long as I am not using compressed textures. My hope now is that
IF my program encounters a compressed texture then it would be able to read a
pixel from video-memory through glReadPixels. That function is capable of
reading only one pixel or a few pixels, so I assume that reading from a
compressed texture means that it will decompress in order to read the pixel.
Doing so would make my intersection code robust as it would handle node-files
that contain compressed images.
Cheers,
Viggo
> From: [EMAIL PROTECTED]> To: [email protected]> Date: Fri, 1
> Aug 2008 13:45:03 +0200> Subject: Re: [osg-users] I want to read one pixel
> from a texture in video memory, back to system memory.> > Hi Viggo,> > Have
> you tried to setup the glReadBuffer properly first. > Take a look into
> osgPPU, this has already the functionality to read from > textures
> (UnitOutCapture) and to be used for post-processing calculation like > you
> have.> > Maybe this could help you to solve the problem.> > Best regards,>
> Art> > > On Thursday 31 July 2008 08:48:19 Viggo Løvli wrote:> > Hi,> >> > I
> am trying to write an intersect post-processing function that will read> >
> the alpha value of the hit-location. I have so far managed to get the> >
> texture coordinates for each collision point. I have also managed to find> >
> which texture (in unit 0) that is used by the object that I collide with.> >>
> > I have a pointer to the texture:> > osg::Texture2D* texture;> >> > The
> scene I am intersecting is read from a pre-created file and all> > osgImage
> data is automatically deleted. So, I can not always use> >
> texture->getImage() and read the pixels from there.> >> > In the cases where
> getImage returns a NULL pointer:> > osg::Texture::TextureObject* to =
> texture->getTextureObject( 0 );> > glBindTexture( GL_TEXTURE_2d, to->_id );>
> > unsigned char data[4];> > glReadPixels( xLocation, yLocation, 1, 1,
> GL_RGBA, GL_UNSIGNED_BYTE,> > data ); glBindTexture( GL_TEXTURE_2D, 0 );> >>
> > This code compiles and it runs. The problem is that it always returns the>
> > same values for RGB and A, nomatter what my xLocation and yLocation is.> >>
> > Can anybody see what I am doing wrong?> >> > Regards,> > Viggo> >> >
> _________________________________________________________________> > Morsomme
> klipp, kjendiser og mer på MSN Video.> >
> http://video.msn.com/?mkt=nb-no&from=HMTAG> > >
> _______________________________________________> osg-users mailing list>
> [email protected]>
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_________________________________________________________________
Hold kontakten med Windows Live Messenger.
http://clk.atdmt.com/GBL/go/msnnkdre0010000003gbl/direct/01/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org