[osg-users] getFrameBufferObject from a child camera

Steven Powers StevenAPowers at gmail.com
Thu Apr 21 14:56:43 PDT 2016


I've added a camera as a child to the main view camera. This camera renders to a texture using a FBO.

I'm trying to get the FBO of this child camera so I can redirect it to different textures during runtime.

I'm attempting to get the FBO using this technique but its not working when the camera is added as a child camera. It seems to work fine if it is added as a slave camera.


Code:
static osg::FrameBufferObject* getFrameBufferObject(osg::RenderInfo& renderInfo)
{
	osg::Camera* camera = renderInfo.getCurrentCamera();
	osgViewer::Renderer* camRenderer = (dynamic_cast<osgViewer::Renderer*>(camera->getRenderer()));
	if (camRenderer != nullptr)
	{
		osgUtil::SceneView* sceneView = camRenderer->getSceneView(0);

		if (sceneView != nullptr)
		{
			osgUtil::RenderStage* renderStage = sceneView->getRenderStage();

			if (renderStage != nullptr)
			{
				return renderStage->getFrameBufferObject();
			}
		}
	}

	return nullptr;
}




The problem is that the renderer returned from getRenderer() does not cast to the osgViewer::Renderer and it returns without finding the FBO.

Any idea what I'm doing wrong?

Thank you!

Cheers,
Steven
Code:




------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66917#66917








More information about the osg-users mailing list