32 lines
883 B
C++
32 lines
883 B
C++
|
#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;
|
|||
|
}
|