[osg-users] How to convert osg::Texture to osg::Image?

michael kapelko kornerr at gmail.com
Tue May 19 20:05:24 PDT 2015


I want to make sure I got you right.
There's no way to convert Texture to Image, I can only get the Image at the
time of Camera draw operation. Thus, it would be easier to attach the Image
to Camera. Correct?

2015-05-19 20:27 GMT+07:00 Robert Osfield <robert.osfield at gmail.com>:

> Hi Michael,
>
> A Texture attached to an osg::Camera for RTT will not have an
> osg::Image assigned to it, it's assigned to a frame buffer object
> instead.
>
> What you need to do is attach a final draw callback on the RTT Camera
> that does a osg::Image::readPixels(..) or
> osg::Image::readImageFromCurrentTexture(..).  You could leave this
> callback attached all the time and just have a flag in it that toggles
> on/off whether the read to image needs to be done or not.
>
> Robert.
>
> On 19 May 2015 at 14:24, michael kapelko <kornerr at gmail.com> wrote:
> > Hi.
> > I have osg::Texture that is attached to camera, it contains a rendered
> scene
> > (deferred rendering). I want to save it to a PNG file.
> > I tried to use osg::Texture::getImage(), but the resulting osg::Image
> seems
> > to be invalid, because osgDB::writeImageFile() crashes with it.
> > What's the correct way to convert Texture to Image?
> > Thanks.
> >
> > _______________________________________________
> > osg-users mailing list
> > osg-users at lists.openscenegraph.org
> >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150520/e0479689/attachment-0003.htm>


More information about the osg-users mailing list