|
我用多窗口来渲染场景,用了compositeviewer的方式来产生两个窗口,compositeviewer下有viewer1与viewer2,由于特殊用途我让两个窗口重叠显示即一个完全盖住另外一个,然后分别对每一个窗口截图,
我用的代码
viewer1->getCamera()->setPostDrawCallback(new CaptuerDrawCallBack(image_c.get()));
//viewer2->getCamera()->setPostDrawCallback(new CaptuerDrawCallBack(image_c.get()));
c_viewer->frame();
这里CaptuerDrawCallBack是
struct CaptuerDrawCallBack:public osg::Camera:rawCallback
{
CaptuerDrawCallBack(osg::ref_ptr<osg::Image>image)
{
_image=image;
}
~CaptuerDrawCallBack(){}
virtual void operator()(const osg::Camera& camera)const
{
osg::ref_ptr<osg::GraphicsContext::WindowingSystemInterface>win;
_image->allocateImage(720,576,1,GL_RGBA,GL_UNSIGNED_BYTE);
_image->readPixels(0,0,720,576,GL_RGBA,GL_UNSIGNED_BYTE);
pData=_image->data();
}
osg::ref_ptr<osg::Image>_image;
};
截不到图该如何解决?
谢谢! |
|