This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/OpenGL/lab4/main.cpp

32 lines
883 B
C++
Raw Normal View History

2023-06-04 09:17:08 +00:00
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osgText/Text>
#include <osgGA/TrackballManipulator>
#include <osgGA/GUIEventAdapter>
#include <osgViewer/ViewerEventHandlers>
using namespace std;
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())
{
viewer.frame();
}
return 0;
}