|
本帖最后由 acmiyou 于 2009-9-2 21:50 编辑
有没有人用OSG 在MFC里头实现 类似附件的多视图的显示.
为什么 我使用CompositeViewer::addView却没法显示 而且会闪烁..- void CompositeOSG::addView(HWND hwnd)
- {
- osgViewer::View* view = new osgViewer::View;
- viewer->addView(view);
- view->setSceneData(rootNode.get());
- // Add a Stats Handler to the viewer
- view->addEventHandler(new osgViewer::StatsHandler);
-
- RECT rect;
- // Get the current window size
- ::GetWindowRect(hwnd, &rect);
- // Init the GraphicsContext Traits
- osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
- // Init the Windata Variable that holds the handle for the Window to display OSG in.
- osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowWin32::WindowData(hwnd);
- // Setup the traits parameters
- traits->x = 0;
- traits->y = 0;
- traits->width = rect.right - rect.left;
- traits->height = rect.bottom - rect.top;
- traits->windowDecoration = false;
- traits->doubleBuffer = true;
- traits->sharedContext = 0;
- traits->setInheritedWindowPixelFormat = true;
- traits->inheritedWindowData = windata;
- osg::GraphicsContext* gc = osg::GraphicsContext::createGraphicsContext(traits.get());
- view->getCamera()->setGraphicsContext(gc);
- view->getCamera()->setViewport(new osg::Viewport(traits->x, traits->y, traits->width, traits->height));
- view->getCamera()->setDrawBuffer(GL_BACK);
- view->getCamera()->setReadBuffer(GL_BACK);
- view->setCameraManipulator(new osgGA::TrackballManipulator);
- }
复制代码 我用MFC 分割了两个子视图..结果只会显示背景.没能显示模型.其中的rootNode 初始化为cow.osg..
并且显示的窗口会闪烁..
附加的图是我用OpenGL 画的..>_< |
-
|