Hello,

(1)to J.P.

the related source code is as following:

// camera and image setup
osg::Camera::RenderTargetImplementation renderTargetImplementation;
renderTargetImplementation = osg::CameraNode::FRAME_BUFFER;

osg::Program * program = new osg::Program();
program->addShader(osg::Shader::readShaderFile(osg::Shader::FRAGMENT, 
fragmentShaderPath));
program->addShader(osg::Shader::readShaderFile(osg::Shader::VERTEX, 
vertexShaderPath));

osg::Image * image = new osg::Image();
image->allocateImage((int)XRes, (int)YRes, 1, GL_RGBA, GL_FLOAT);

osg::ref_ptr<osg::CameraNode>  camera(new osg::CameraNode());
camera->setClearColor(osg::Vec4(1000.0f, 1000.0f, 1000.0f, 1000.0f));
camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
camera->setRenderOrder(osg::CameraNode::PRE_RENDER);
camera->setRenderTargetImplementation(renderTargetImplementation);
camera->attach(osg::CameraNode::COLOR_BUFFER, image);
camera->getOrCreateStateSet()->setAttribute(program, osg::StateAttribute::ON);

// access data  (only for instance)
osg::Vec4f * fragments = (osg::Vec4f *)(image->data());
osg::Vec4f  color= distances[10];
float color_a= distances[3];

As can be seen from the source code, I attach an image to the camera, and 
access data from the image,
I am rendering to an FBO.

So would you please give me some advice further?

Thank you very much!


*(2) to Paul*

Refer to (1) of this message, does  osg::CameraNode::COLOR_BUFFER imply a RGB  
or  RGBA buffer
? or it doesn't even matter?

Thank you very much !

Shuiying


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

Reply via email to