|
发表于 2014-6-8 19:33:10
|
显示全部楼层
本帖最后由 xingshujun 于 2014-6-9 16:22 编辑
根据上面的思路写了一个四缓冲写了一个测试的小程序
已知问题:
必须将程序开始时设置为四缓冲模式,运行过程中只能关闭立体,开启四缓冲立体;
其他格式的立体无法开启,例如红蓝,左右格式等
窗口过大时,会无立体效果
看大家有什么方法,可以自由切换成其他立体格式
主要代码如下
- QuadBufferViewerWidget::QuadBufferViewerWidget(ref_ptr<Node> root,QWidget *parent )
- : QWidget(parent),_root(root)
- {
- ui.setupUi(this);
- _ds = osg::DisplaySettings::instance();
- _ds->setStereo(true);
- _ds->setStereoMode(osg::DisplaySettings::QUAD_BUFFER);
- _viewer.setSceneData( root );
- _viewer.setUpViewOnSingleScreen(0);
- _viewer.setCameraManipulator( new osgGA::TrackballManipulator );
- _viewer.realize();
- _viewer.getWindows(_windows);
- _pWin = dynamic_cast<osgViewer::GraphicsWindowWin32*>(_windows[0]);
- _pWin -> setWindowRectangleImplementation(0,0,width(),height());
- _isFirstFrame = true ;
- startTimer(20);
- }
- void QuadBufferViewerWidget::timerEvent( QTimerEvent *event )
- {
- if (_isFirstFrame == true)
- {
- ::SetParent(_pWin->getHWND(),winId());
- _viewer.frame();
- _ds->setStereo(false);
- _isFirstFrame = false ;
- }
- _viewer.frame();
- }
- void QuadBufferViewerWidget::resizeEvent( QResizeEvent * event )
- {
- _pWin->setWindowRectangleImplementation(0,0,width(),height());
- }
- void QuadBufferViewerWidget::setStereoCommon()
- {
- _ds->setStereo(false);
- }
- void QuadBufferViewerWidget::setStereoQuad()
- {
- _ds->setStereo(true);
- _ds->setStereoMode(osg::DisplaySettings::QUAD_BUFFER);
- }
复制代码
下载地址:
http://pan.baidu.com/s/1dDIN6GL
|
|