|
楼主 |
发表于 2011-4-15 18:17:06
|
显示全部楼层
回复 2# array
MFC开了两个窗口,对应两个viewer
viewer1->setCamera( camera1.get() );
viewer2->setCamera( camera2.get() );
......
osg::ref_ptr<osg::Image>image_c=new osg::Image();
osg::ref_ptr<osg::Image>image_v=new osg::Image();
camera1->setPostDrawCallback(new CaptuerDrawCallBack_cam2(image_v.get()));
camera2->setPostDrawCallback(new CaptuerDrawCallBack_cam1(image_c.get()));
......
这是我两个回调的实现
struct CaptuerDrawCallBack_cam1:public osg::Camera:rawCallback
{
CaptuerDrawCallBack_cam1(osg::ref_ptr<osg::Image>image)
{
_image=image;
}
~CaptuerDrawCallBack_cam1(){}
virtual void operator()(const osg::Camera& camera)const
{
osg::ref_ptr<osg::GraphicsContext::WindowingSystemInterface>win;
//osg::GraphicsContext* gc = renderInfo.getState()->getGraphicsContext();
_image->allocateImage(720,576,1,GL_RGBA,GL_UNSIGNED_BYTE);
_image->readPixels(0,0,720,576,GL_RGBA,GL_UNSIGNED_BYTE);
//osgDB::writeImageFile((*_image.get()),"image.bmp");
pData1=_image->data();
_image->dirty();
}
osg::ref_ptr<osg::Image>_image;
};
struct CaptuerDrawCallBack_cam2:public osg::Camera::DrawCallback
{
CaptuerDrawCallBack_cam2(osg::ref_ptr<osg::Image>image)
{
_image=image;
}
~CaptuerDrawCallBack_cam2(){}
virtual void operator()(const osg::Camera& camera)const
{
osg::ref_ptr<osg::GraphicsContext::WindowingSystemInterface>win;
//osg::GraphicsContext* gc = renderInfo.getState()->getGraphicsContext();
_image->allocateImage(720,576,1,GL_RGBA,GL_UNSIGNED_BYTE);
_image->readPixels(0,0,720,576,GL_RGBA,GL_UNSIGNED_BYTE);
//osgDB::writeImageFile((*_image.get()),"image.bmp");
pData=_image->data();
_image->dirty();
}
osg::ref_ptr<osg::Image>_image;
};
有一个总是抓不上 |
|