changed: gcc8 base update
[opensg.git] / Examples / Tutorial / 00framework.cpp
blob52d4089b366321b66f798451adb4cd183d53cd39
2 // all needed include files
3 #ifdef OSG_BUILD_ACTIVE
4 #include <OSGGLUT.h>
5 #include <OSGConfig.h>
6 #include <OSGSimpleGeometry.h>
7 #include <OSGGLUTWindow.h>
8 #include <OSGSimpleSceneManager.h>
9 #else
10 #include <OpenSG/OSGGLUT.h>
11 #include <OpenSG/OSGConfig.h>
12 #include <OpenSG/OSGSimpleGeometry.h>
13 #include <OpenSG/OSGGLUTWindow.h>
14 #include <OpenSG/OSGSimpleSceneManager.h>
15 #endif
17 OSG::SimpleSceneManagerRefPtr mgr;
18 OSG::NodeRecPtr scene;
20 int setupGLUT( int *argc, char *argv[] );
22 OSG::NodeTransitPtr createScenegraph(void)
24 // the scene must be created here
26 return OSG::NodeTransitPtr();
29 int main(int argc, char **argv)
31 OSG::osgInit(argc,argv);
34 int winid = setupGLUT(&argc, argv);
35 OSG::GLUTWindowRecPtr gwin = OSG::GLUTWindow::create();
36 gwin->setGlutId(winid);
37 gwin->init();
39 scene = createScenegraph();
41 mgr = OSG::SimpleSceneManager::create();
42 mgr->setWindow(gwin );
43 mgr->setRoot (scene);
44 mgr->showAll();
47 glutMainLoop();
49 return 0;
52 void reshape(int w, int h)
54 mgr->resize(w, h);
55 glutPostRedisplay();
58 void display(void)
60 mgr->redraw();
63 void mouse(int button, int state, int x, int y)
65 if (state)
66 mgr->mouseButtonRelease(button, x, y);
67 else
68 mgr->mouseButtonPress(button, x, y);
70 glutPostRedisplay();
73 void motion(int x, int y)
75 mgr->mouseMove(x, y);
76 glutPostRedisplay();
79 int setupGLUT(int *argc, char *argv[])
81 glutInit(argc, argv);
82 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
84 int winid = glutCreateWindow("OpenSG First Application");
86 glutDisplayFunc(display);
87 glutMouseFunc(mouse);
88 glutMotionFunc(motion);
89 glutReshapeFunc(reshape);
90 glutIdleFunc(display);
91 return winid;