1 // all needed include files
2 #ifdef OSG_BUILD_ACTIVE
5 #include <OSGSimpleGeometry.h>
6 #include <OSGGLUTWindow.h>
7 #include <OSGSimpleSceneManager.h>
9 #include <OSGThreadManager.h>
11 #include <OpenSG/OSGGLUT.h>
12 #include <OpenSG/OSGConfig.h>
13 #include <OpenSG/OSGSimpleGeometry.h>
14 #include <OpenSG/OSGGLUTWindow.h>
15 #include <OpenSG/OSGSimpleSceneManager.h>
17 #include <OpenSG/OSGThreadManager.h>
20 OSG::SimpleSceneManagerRefPtr mgr
;
21 OSG::NodeRecPtr scene
;
23 int setupGLUT(int *argc
, char *argv
[]);
25 OSG::NodeTransitPtr
createScenegraph(void)
27 // the scene must be created here
28 OSG::NodeRecPtr n
= OSG::makeSphere(2,2);
29 return OSG::NodeTransitPtr(n
);
32 void printA(void *args
)
35 SLOG
<< "Thread One 11111" << std::endl
;
38 void printB(void *args
)
41 SLOG
<< "Thread Two 22222" << std::endl
;
44 int main(int argc
, char **argv
)
46 OSG::osgInit(argc
,argv
);
49 int winid
= setupGLUT(&argc
, argv
);
50 OSG::GLUTWindowRecPtr gwin
= OSG::GLUTWindow::create();
51 gwin
->setGlutId(winid
);
54 scene
= createScenegraph();
56 mgr
= OSG::SimpleSceneManager::create();
57 mgr
->setWindow(gwin
);
61 OSG::ThreadRefPtr threadOne
=
62 OSG::dynamic_pointer_cast
<OSG::Thread
>(
63 OSG::ThreadManager::the()->getThread("One", false));
65 OSG::ThreadRefPtr threadTwo
=
66 OSG::dynamic_pointer_cast
<OSG::Thread
>(
67 OSG::ThreadManager::the()->getThread("Two", false));
69 threadOne
->runFunction(printA
, 1, NULL
);
70 threadTwo
->runFunction(printB
, 1, NULL
);
80 void reshape(int w
, int h
)
91 void mouse(int button
, int state
, int x
, int y
)
94 mgr
->mouseButtonRelease(button
, x
, y
);
96 mgr
->mouseButtonPress(button
, x
, y
);
101 void motion(int x
, int y
)
103 mgr
->mouseMove(x
, y
);
107 int setupGLUT(int *argc
, char *argv
[])
109 glutInit(argc
, argv
);
110 glutInitDisplayMode(GLUT_RGB
| GLUT_DEPTH
| GLUT_DOUBLE
);
112 int winid
= glutCreateWindow("OpenSG First Application");
114 glutDisplayFunc(display
);
115 glutMouseFunc(mouse
);
116 glutMotionFunc(motion
);
117 glutReshapeFunc(reshape
);
118 glutIdleFunc(display
);