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

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注