OpenSceneGraph/examples/osgbrowser/osgbrowser.cpp

42 lines
1.2 KiB
C++
Raw Normal View History

#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgWidget/Browser>
int main(int argc,char** argv)
{
osg::ArgumentParser arguments(&argc, argv);
2009-09-04 17:11:49 +08:00
osgWidget::BrowserManager::instance()->init(arguments[0]);
osgViewer::Viewer viewer(arguments);
osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
osg::Vec3(1.0f,0.0f,0.0f),
osg::Vec3(0.0f,0.0f,1.0f),
osg::Vec4(1.0f,1.0f,1.0f,1.0f),
osgWidget::GeometryHints::RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO);
osg::ref_ptr<osg::Group> group = new osg::Group;
for(int i=1; i<arguments.argc(); ++i)
{
if (!arguments.isOption(i))
{
osg::ref_ptr<osgWidget::Browser> browser = new osgWidget::Browser;
if (browser->open(arguments[i], hints))
2009-09-04 17:11:49 +08:00
{
group->addChild(browser.get());
2009-09-04 17:11:49 +08:00
hints.position.x() += 1.1f;
}
}
}
viewer.setSceneData(group.get());
viewer.addEventHandler(new osgViewer::StatsHandler);
return viewer.run();
}