Hi,
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.
Thanks,
Brian
On Fri Jul 27 5:10 , 'Robert Osfield' <[EMAIL PROTECTED]> sent:
>It sounds like you are after:
>
> Image::readImageFromCurrentTexture(..)
>
>This will require the texture to be bound, something you can do via
>Texture::apply(State&).
>
>
>On 7/27/07, Brian [EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I was wondering what the best approach to capturing an image that has been
>> rendered to texture is? In my application, I'm needing to capture frames to
>> file and/or memory buffers at various intervals. In my camera node that I
>> have set up, the texture that is associated has a NULL osg::Image (using
>> getImage()); and I believe that is the case for all RTT examples that I have
>> looked at.
>>
>> I imagine that I could simply bind the texture and call glReadPixels,
>> however it seems to me that doing this might not give the results that I'm
>> wanting which is the actual texture's image. I don't want to do a screen
>> capture, per se, which is what I think that using glReadPixels would
>> ultimately accomplish. Capturing the output of the texture to a buffer is
>> what I need. I am hoping there is a way to do this that is already built
>> into OSG.
>>
>> My first stab at this was to get the TextureObjectList to obtain the texture
>> ID, bind that texture ID, and then call glReadPixels. I've tried the
>> following code, but nothing is ever copied to the data buffer. Of course,
>> my OpenGL knowledge is a bit limited in this area, so I have no idea as to
>> the correctness of this approach. Any help would be greatly appreciated.
>>
>> osg::Image *image = tex->getImage();
>> unsigned char *data = new unsigned char[512 * 512 *4];
>>
>> osg::Texture::TextureObjectListMap map;
>>
>> tex->takeTextureObjects(map);
>> osg::Texture::TextureObjectList& tol = map[0];
>>
>> // reset the time of any uninitialized objects.
>> osg::Texture::TextureObjectList::iterator iter;
>> iter = tol.begin();
>>
>> osg::Texture::TextureObject* obj = (*iter).get();
>>
>> if (data && obj)
>> {
>> glBindTexture(GL_TEXTURE_2D, obj->_id);
>> glReadPixels(0, 0, obj->_width, obj->_height, GL_RGBA,
>> GL_UNSIGNED_BYTE, data);
>> glBindTexture(GL_TEXTURE_2D, 0);
>> }
>>
>>
>> Thanks,
>> Brian
>>
>>
>>
>>
>> _______________________________________________
>> 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
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org