您好,登錄后才能下訂單哦!
OpenSceneGraph中的窗體模式運行是怎樣的,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。
1.使用osgViewer::Viewer代替原來的osgProducer::Viewer 2.先熟悉設計模式,比如最常用的Visitor設計模式。要不然看不懂程序不說,而且更寫不出程序。 3.窗體模式運行參考Example osgWindows,在這個例子中重點在于:
osg::ref_ptr traits = new osg::GraphicsContext::Traits; traits->x = 640; traits->y = 0; traits->width = 640; traits->height = 480; traits->windowDecoration = true; traits->doubleBuffer = true; traits->sharedContext = 0; osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr camera = new osg::Camera; camera->setGraphicsContext(gc.get()); camera->setViewport(new osg::Viewport(0,0, traits->width, traits->height)); GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; camera->setDrawBuffer(buffer); camera->setReadBuffer(buffer); // add this slave camra to the viewer, with a shift right of the projection matrix viewer.addSlave(camera.get(), osg::Matrixd::translate(-1.0,0.0,0.0), osg::Matrixd());
另外Example osgkeyboardmouse也提到了另外一種方式:
// create the window to draw to. osg::ref_ptr traits = new osg::GraphicsContext::Traits; traits->x = 200; traits->y = 200; traits->width = 800; traits->height = 600; traits->windowDecoration = true; traits->doubleBuffer = true; traits->sharedContext = 0; osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osgViewer::GraphicsWindow* gw = dynamic_cast(gc.get()); if (!gw) { osg::notify(osg::NOTICE)<<"Error: unable to create graphics window."< return 1; } gw->realize(); gw->makeCurrent(); // create the view of the scene. osgViewer::SimpleViewer viewer; viewer.setSceneData(loadedModel.get()); viewer.setEventQueue(gw->getEventQueue()); viewer.getEventQueue()->windowResize(traits->x,traits->y,traits->width,traits->height);
TODO: 1.3DS導入插件還不夠完善,需要自己寫。 2.更深入的了解OSG的機制。
看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注億速云行業資訊頻道,感謝您對億速云的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。