您好,登錄后才能下訂單哦!
OpenSceneGraph中的窗體模式運(yùn)行是怎樣的,很多新手對此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
1.使用osgViewer::Viewer代替原來的osgProducer::Viewer 2.先熟悉設(shè)計(jì)模式,比如最常用的Visitor設(shè)計(jì)模式。要不然看不懂程序不說,而且更寫不出程序。 3.窗體模式運(yùn)行參考Example osgWindows,在這個(gè)例子中重點(diǎn)在于:
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導(dǎo)入插件還不夠完善,需要自己寫。 2.更深入的了解OSG的機(jī)制。
看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注億速云行業(yè)資訊頻道,感謝您對億速云的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。