After looking into this further, it seemed that using glGetTexImage
would be able to copy from a texture used as a render target (FBO).  I
have tried this only to be left with a black texture that never gets
filled in.  I know that function works by grabbing whatever texture is
currently bound and returning its data.  Using osg, the way to do this
seemed to be the following:

 

osg::GraphicsContext *context = cam->getGraphicsContext();

osg::State *currentState = context->getState();

 

currentState->setActiveTextureUnit(0);

currentState->applyTextureAttribute(0, mColorTexture);

 

osg::ref_ptr<osg::Image> imageCapture = new osg::Image;

imageCapture->readImageFromCurrentTexture(0, false);

 

Unfortunately imageCapture is entirely filled with zeros.

 

Anyone have some ideas or experience with this sort of thing?

 

Thanks,

Michael Guerrero

 

________________________________

From: Guerrero, Michael (CIV) 
Sent: Tuesday, April 01, 2008 2:23 PM
To: OpenSceneGraph Users
Subject: [osg-users] Getting the Image from a Texture2D used as a render
target

 

Hi, I'm trying to retrieve texture data that I have rendered from video
memory back to main memory.  I was initially hoping I could set up a
render target as usual and then just call GetImage on the Texture2D but
that doesn't work.  Is there any easy way to do this?

 

Thanks,

Michael Guerrero

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to