|
楼主 |
发表于 2011-4-27 12:41:38
|
显示全部楼层
回复 2# array
请帮我看一下
//初始化主视图
osg::ref_ptr<osg::Camera> cameraMaster = new osg::Camera ;
osg:isplaySettings* ds1 = cameraMaster->getDisplaySettings();
if (!ds1) ds1 = osg::DisplaySettings::instance();
if (ds1) ds1->setStereo(true);
ds1->setStereoMode(osg::DisplaySettings::VERTICAL_INTERLACE);//1立体
cameraMaster->setDisplaySettings(ds1);
//相机视口设置
cameraMaster->setViewport(new osg::Viewport(traits ->x, traits ->y, traits ->width, traits ->height));
cameraMaster->addChild(node1);
//初始化子视图
osg::ref_ptr<osg::Camera> leftViewer = new osg::Camera ;
osg::DisplaySettings* ds2 = leftViewer->getDisplaySettings();
if (!ds2) ds2 = osg::DisplaySettings::instance();
if (ds2) ds2->setStereo(true);
ds2->setStereoMode(osg::DisplaySettings::ANAGLYPHIC);//2立体
leftViewer->setDisplaySettings(ds2);
leftViewer->setViewport(new osg::Viewport((traits ->width/4)*3-2,0, traits ->width/4, traits ->height/4));
GLenum bufferleft = traits ->doubleBuffer ? GL_BACK : GL_FRONT;
leftViewer->setDrawBuffer(bufferleft);
leftViewer->setReadBuffer(bufferleft);
leftViewer->addChild(node2);
root->addChild(cameraMaster);
root->addChild(leftViewer);
viewer.setSceneData(root);
这样执行的时候,两个窗口都是ANAGLYPHIC立体,而上面的立体VERTICAL_INTERLACE的设置没起到作用,子视图中立体设为false时,则两个视图都没立体。只有当子视图中的设置立体部分注释了,则整个场景都为VERTICAL_INTERLACE立体。好像是子视图中的设置覆盖了主视图中立体的设置
不知道为什么。。。。。。 |
|