一、全屏
#include <osgViewer/Viewer> #include <osgDB/ReadFile> #include <osgGA/GUIEventAdapter> #include <osgViewer/ViewerEventHandlers> int main() { osg::ref_ptr<osgViewer::Viewer> view = new osgViewer::Viewer; osg::ref_ptr<osg::Node> node = new osg::Node; //node = osgDB::readNodeFile("glider.osg"); node = osgDB::readNodeFile("cow.osg"); view->addEventHandler(new osgViewer::WindowSizeHandler);//全屏 快捷键f view->setSceneData(node); return view->run(); }
二、查看帧数
#include <osgViewer/Viewer> #include <osgDB/ReadFile> #include <osgGA/GUIEventAdapter> #include <osgViewer/ViewerEventHandlers> int main() { osg::ref_ptr<osgViewer::Viewer> view = new osgViewer::Viewer; osg::ref_ptr<osg::Node> node = new osg::Node; //node = osgDB::readNodeFile("glider.osg"); node = osgDB::readNodeFile("cow.osg"); //方法一 // view->addEventHandler(new osgViewer::StatsHandler);//查看帧数 s //方法二 osgViewer::StatsHandler* pStatsHandler = new osgViewer::StatsHandler; pStatsHandler->setKeyEventTogglesOnScreenStats(osgGA::GUIEventAdapter::KEY_F11); view->addEventHandler(pStatsHandler); view->setSceneData(node); return view->run(); }
三、截图
#include <osgViewer/Viewer> #include <osgDB/ReadFile> #include <osgGA/GUIEventAdapter> #include <osgViewer/ViewerEventHandlers> int main() { osg::ref_ptr<osgViewer::Viewer> view = new osgViewer::Viewer; osg::ref_ptr<osg::Node> node = new osg::Node; //node = osgDB::readNodeFile("glider.osg"); node = osgDB::readNodeFile("cow.osg"); view->addEventHandler(new osgViewer::ScreenCaptureHandler);//截图 快捷键 c view->setSceneData(node); return view->run(); }