赞助

OSG 常用快捷键(全屏、查看帧数、截屏)

一、全屏

#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();
}

 

posted @ 2021-07-23 21:48  车臣  阅读(1774)  评论(0编辑  收藏  举报