40 lines
No EOL
1.1 KiB
C++
40 lines
No EOL
1.1 KiB
C++
#include <osgViewer/Viewer>
|
||
#include <osgDB/ReadFile>
|
||
#include <osgText/Text>
|
||
#include <osgGA/TrackballManipulator>
|
||
#include <chrono>
|
||
#include <osgGA/GUIEventAdapter>
|
||
#include <osgViewer/ViewerEventHandlers>
|
||
|
||
using namespace std;
|
||
using namespace chrono;
|
||
|
||
auto lastFT = system_clock::now();
|
||
auto FT = system_clock::now();
|
||
|
||
int main(int argc, char** argv)
|
||
{
|
||
// 创建一个OSG Viewer对象
|
||
osgViewer::Viewer viewer;
|
||
viewer.setUpViewInWindow(50, 50, 800, 600);
|
||
viewer.getCamera()->setClearColor(osg::Vec4(0.2, 0.2, 0.2, 1.0));
|
||
viewer.setCameraManipulator(new osgGA::TrackballManipulator);
|
||
|
||
viewer.addEventHandler(new osgViewer::StatsHandler);//查看帧数 s
|
||
|
||
// 创建一个OSG Node对象,并加载OSG模型
|
||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile("clock.osgt");
|
||
|
||
// 将Node对象添加到OSG Viewer中
|
||
viewer.setSceneData(model);
|
||
// 启动OSG Viewer循环
|
||
while (!viewer.done())
|
||
{
|
||
auto thisFT = system_clock::now();
|
||
auto FT = duration_cast<microseconds>(thisFT - lastFT);
|
||
lastFT = thisFT;
|
||
viewer.frame();
|
||
}
|
||
|
||
return 0;
|
||
} |