openSG程序简单框架

来源:互联网 发布:java聊天系统制作 编辑:程序博客网 时间:2024/04/29 01:46

openSG程序简单框架
1、包含所需的基本的头文件
#include <OpenSG/OSGConfig.h>           //OpenSG的基本配置
#include <OpenSG/OSGGLUT.h>           //OpenSG窗体
#include <OpenSG/OSGSimpleGeometry.h>         
#include <OpenSG/OSGGLRTWindow.h>            
#include <OpenSG/OSGSimpleSceneManager.h> //OpenSG屏幕管理
2、引入OpenSG命名空间
OPG_USING_NAMESPACE
3、OpenSG程序流程
1、初始化OpenSG子系统
osgInit(argc,argv);         
2、创建并设置GLUT(可封装为一个函数setGlut(int * argc,char ** argv)
glutInit(argc,argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH_GLUT_DOUBLE);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMotionFunc(motion);
glutMouseFunc(mouse);
int wind = glutCreateWindow(“OpenSG First Application”);
3、创建并设置GLUTWindowPtr
GLUTWindowPtr gwin = GLUTWindow::create();
gwin->setId(wind);
gwin->init();
4、创建NodePtr
NodePtr scene = makeTorus(0.5,2,16,16);
5、创建并设置SimpleSceneManager;
SimpleSceneManager mgr = new SimpleSceneManager;
mgr->setWindow(gwin);
mgr->setRoot(scene);
6、显示图形
mgr->showAll();
7、循环显示
glutMainLoop();
 
 
GLUT——〉GLUTWindowPtr——〉
SimpleSceneManager
                                    NodePtr——〉