diff --git a/examples/osgscreencapture/osgscreencapture.cpp b/examples/osgscreencapture/osgscreencapture.cpp index 82186ca7c..f95a0aa39 100644 --- a/examples/osgscreencapture/osgscreencapture.cpp +++ b/examples/osgscreencapture/osgscreencapture.cpp @@ -29,6 +29,68 @@ #include +class WindowCaptureCallback : public osg::Camera::DrawCallback +{ + public: + + WindowCaptureCallback() + { + } + + virtual void operator () (osg::RenderInfo& renderInfo) const + { + osg::GraphicsContext* gc = renderInfo.getState()->getGraphicsContext(); + osg::notify(osg::NOTICE)<<"Capture screen image "<getCameras(); + osg::Camera* lastCamera = 0; + for(osg::GraphicsContext::Cameras::iterator cam_itr = cameras.begin(); + cam_itr != cameras.end(); + ++cam_itr) + { + if (lastCamera) + { + if ((*cam_itr)->getRenderOrder() > (*cam_itr)->getRenderOrder()) + { + lastCamera = (*cam_itr); + } + if ((*cam_itr)->getRenderOrder() == lastCamera->getRenderOrder() && + (*cam_itr)->getRenderOrderNum() >= lastCamera->getRenderOrderNum()) + { + lastCamera = (*cam_itr); + } + } + else + { + lastCamera = *cam_itr; + } + } + + if (lastCamera) + { + osg::notify(osg::NOTICE)<<"Last camera "<setFinalDrawCallback(callback); + } + else + { + osg::notify(osg::NOTICE)<<"No camera found"<