Hi Trystan,

Have a look at :

   Image::readImageFromCurrentTexture(..)

You'd need to call this from the graphics thread that has you've have
render to the texture from - for instance using a Camera Post or
FinalDrawCallback.

After this readImage you could do the writeImageFile as well to ensure
that the correct ordering is maintained.  Calling writeImageFile()
after the viewer.frame() will only work in SingleThreaded and
CullDrawThreadPerContext threading models as the other threading
models have the graphics thread still running after the return form
viewer.frame().

Robert.


On 12 November 2011 07:52, Trystan Larey-Williams <[email protected]> wrote:
> Hi,
>
> I've been banging my head against how to save a 3D texture out to a dds file 
> for some time now. I've read posts that suggest simply attaching the 
> texture's image to the buffer rather than the texture itself. I've done that 
> for 2D textures with no problem. However, I don't see how that will work in 
> this case; given the setup below.
>
>
> Code:
>
> ...
> camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
> camera->setImplicitBufferAttachmentMask(osg::Camera::IMPLICIT_COLOR_BUFFER_ATTACHMENT,
>  osg::Camera::IMPLICIT_COLOR_BUFFER_ATTACHMENT );
> camera->attach(osg::Camera::COLOR_BUFFER0, tex1, 0, 
> osg::Camera::FACE_CONTROLLED_BY_GEOMETRY_SHADER);
> camera->attach(osg::Camera::COLOR_BUFFER1, tex2, 0, 
> osg::Camera::FACE_CONTROLLED_BY_GEOMETRY_SHADER);
> viewer.frame();
> ...
>
>
>
>
> So, after I render the frame I want to be able to say
>
> Code:
>
> osgDB::writeImageFile( *tex1->getImage(), "foo.dds" )
>
>
>
>
> But, of course, this doesn't work since the image isn't updated when the 
> texture changes. Is there a strait forward way to get the texture data back 
> to an image that I'm missing?
>
> Thank you!
>
> Cheers,
> Trystan[/code][/list]
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=43837#43837
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to