Hi all,

I would like to render a depth image via FBO with a
current OpenSG 2.0.
Quite a common operation, so can someone post a code fragment for it perhaps?

I have tried the code below so far without success.
Getting the color image works without any problems ..

void computeHeightfieldImage (OSG::Node* root, 
                              OSG::UInt32 x, OSG::UInt32 y,
                              OSG::NodeUnrecPtr& stageN,
                              OSG::ImageRefPtr&  image)
{
   // create FBO
   image = OSG::Image::create();
   image->set(OSG::Image::OSG_L_PF, 
              x, y, 1, 1, 1,
              0.0,
              0,
              OSG::Image::OSG_FLOAT32_IMAGEDATA);

   OSG::FrameBufferObjectRefPtr fbo = OSG::FrameBufferObject::create();
   OSG::RenderBufferRefPtr     depthBuf  = OSG::RenderBuffer::create(); 
   depthBuf->setImage(image);
   depthBuf->setInternalFormat(GL_DEPTH_COMPONENT32);    
   OSG::RenderBufferRefPtr     texBuf = OSG::RenderBuffer::create();
   texBuf  ->setInternalFormat(GL_RGB);    
   // make the fbo render to the texture
   fbo->setColorAttachment(texBuf, 0);
   fbo->setDepthAttachment(depthBuf );
   fbo->editMFDrawBuffers()->push_back(GL_COLOR_ATTACHMENT0_EXT);
   fbo->setWidth (x);
   fbo->setHeight(y);
   depthBuf->setReadBack          (true);
   fbo->setPostProcessOnDeactivate(true);
..
}

Thanks,
Christoph 
-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to