[osg-users] Is it possible to temporarily redirect the main camera of a view?

Ravi Mathur ravidavi at utexas.edu
Fri Mar 24 21:12:26 PDT 2017

Hi Werner,

Instead of modifying the main camera attachments, you might want to create a slave camera whose sole purpose is to render to FBO. Then you can enable/disable that camera using slaveCamera->setNodeMask (0x0 to disable, 0xffffffff) to enable.


// Create slave camera and set its attachment
osg::Camera *slaveCamera = new osg::Camera;
/** Create & attach your image here */

// Add slave camera to view and set its projection offset matrix
view->addSlave(slaveCamera, true) // true = use master camera's scene
osg::View::Slave *theSlave = view->findSlaveForCamera(slaveCamera);
theSlave->_projectionOffset = offsetMatrix;

// Enable slave when you want to render to FBO

// Disable camera on the next frame

// Profit

Hope this helps,

Read this topic online here:

More information about the osg-users mailing list