|
- osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
- traits->x = 0;
- traits->y = 0;
- traits->width = width*2;
- traits->height = height*2;
- traits->depth = 16; //keep memory down, default is currently 24
- traits->windowDecoration = true;
- traits->doubleBuffer = true;
- traits->sharedContext = 0;
- traits->setInheritedWindowPixelFormat = true;
- traits->inheritedWindowData = _window;
- osg::ref_ptr<osg::GraphicsContext> graphicsContext = osg::GraphicsContext::createGraphicsContext(traits.get());
-
-
- if (_viewer == NULL) {
- _viewer = new osgViewer::Viewer();
- }
- if(graphicsContext)
- {
- _viewer->getCamera()->setGraphicsContext(graphicsContext);
- _viewer->getCamera()->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
- }
- _viewer->setCameraManipulator(new osgGA::MultiTouchTrackballManipulator);
- _viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);//SingleThreaded DrawThreadPerContext
- _viewer->getCamera()->setClearColor(osg::Vec4f(0.3,0.3,0.5,1.0));
- _viewer->getViewerStats()->collectStats("scene", true);
复制代码
我想在ipad显示我的模型。我使用Traits设置osgViewer的上下文后模型被拉伸了效果如图1,有没有大神能告诉我如何解决,代码中存在什么问题么? |
-
图1
|