Hi,
I found that I had to attach an image to the texture as follows to get
the copy to work. I was then able to save the image to disk in the
PostDrawCallback. The code is modified from the osgPreRender example
project.
m_pCamera->attach( osg::Camera::COLOR_BUFFER, m_pTexture );
// Test image output
osg::Image* image = new osg::Image;
image->allocateImage( m_nTexWidth, m_nTexHeight, 1, GL_RGBA,
GL_UNSIGNED_BYTE);
// attach the image so its copied on each frame.
m_pCamera->attach( osg::Camera::COLOR_BUFFER, image );
m_pCamera->setPostDrawCallback( new MyCameraPostDrawCallback(
image ) );
m_pTexture->setImage( 0, image );
Gordon
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Robert
Osfield
Sent: Friday, July 27, 2007 11:41 AM
To: [email protected]
Subject: Re: [osg-users] Trying to save a render to texture image
Hi Brian,
On 7/27/07, Brian <[EMAIL PROTECTED]> wrote:
> Well, yes and no. That would be great, but when the FrameBufferObject
is set up, it uses a texture in the call to attach.
>
> renderImplementation = osg::CameraNode::FRAME_BUFFER_OBJECT;
> m_CameraNode->setRenderTargetImplementation(renderImplementation);
> m_CameraNode->attach(osg::CameraNode::COLOR_BUFFER,
m_Texture.get());
>
> Every example I have seen that uses FBOs uses a texture with a NULL
image, unless of course, the FBO initialization fails and then it
reverts to using pbuffers. When I try using m_Texture->getImage(), this
returns NULL, so I have no pointer to use with the
readImageFromCurrentTexture function.
If you attach in Image to a RTT osg::Camera then it should
automatically copy the image at the end of render that subgraph, this
should remove the need to do it manually.
The osgprerender example has a code path that does this.
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org