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

Robert Osfield robert.osfield at gmail.com
Tue May 19 06:27:48 PDT 2015


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
>



More information about the osg-users mailing list