fixed: compile issue
[opensg.git] / Examples / Tutorial / 14clusteringStream_Client.cpp
blob7dd7552c3b18a1a743e70219ba2096b15a677207
1 // all needed include files
2 #ifdef OSG_BUILD_ACTIVE
3 #include <OSGGLUT.h>
4 #include <OSGConfig.h>
5 #include <OSGSimpleGeometry.h>
6 #include <OSGGLUTWindow.h>
7 #include <OSGSimpleSceneManager.h>
9 #include <OSGMultiDisplayWindow.h>
10 #include <OSGSceneFileHandler.h>
11 #else
12 #include <OpenSG/OSGGLUT.h>
13 #include <OpenSG/OSGConfig.h>
14 #include <OpenSG/OSGSimpleGeometry.h>
15 #include <OpenSG/OSGGLUTWindow.h>
16 #include <OpenSG/OSGSimpleSceneManager.h>
18 #include <OpenSG/OSGMultiDisplayWindow.h>
19 #include <OpenSG/OSGSceneFileHandler.h>
20 #endif
22 OSG::SimpleSceneManagerRefPtr mgr;
23 OSG::NodeRecPtr scene;
25 int setupGLUT(int *argc, char *argv[]);
27 int main(int argc, char **argv)
29 OSG::ChangeList::setReadWriteDefault(true);
30 OSG::osgInit(argc,argv);
33 setupGLUT(&argc, argv);
35 //this time we'll have not a GLUTWindow here, but this one
36 OSG::MultiDisplayWindowRecPtr multiWindow =
37 OSG::MultiDisplayWindow::create();
39 //set some necessary values
40 // we connect via multicast
41 multiWindow->setConnectionType("StreamSock");
42 //multiWindow->setServiceAddress("192.168.2.142");
43 // we want to rendering servers...
44 multiWindow->editMFServers()->push_back("Server1");
45 multiWindow->editMFServers()->push_back("Server2");
47 //any scene here
48 scene = OSG::makeTorus(.5, 2, 16, 16);
50 // and the ssm as always
51 mgr = OSG::SimpleSceneManager::create();
53 mgr->setWindow(multiWindow);
54 mgr->setRoot (scene);
55 mgr->showAll();
57 multiWindow->init();
58 multiWindow->resize(512, 512);
60 OSG::commitChanges();
63 glutMainLoop();
65 return 0;
68 void display(void)
70 //redrawing as usual
71 mgr->redraw();
73 //the changelist should be cleared - else things
74 //could be copied multiple times
75 OSG::Thread::getCurrentChangeList()->clear();
77 // to ensure a black navigation window
78 glClear(GL_COLOR_BUFFER_BIT);
79 glutSwapBuffers();
82 void reshape(int w, int h)
84 glutPostRedisplay();
87 void mouse(int button, int state, int x, int y)
89 if (state)
90 mgr->mouseButtonRelease(button, x, y);
91 else
92 mgr->mouseButtonPress(button, x, y);
93 glutPostRedisplay();
96 void motion(int x, int y)
98 mgr->mouseMove(x, y);
99 glutPostRedisplay();
102 int setupGLUT(int *argc, char *argv[])
104 glutInit(argc, argv);
105 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
107 int winid = glutCreateWindow("OpenSG");
109 glutReshapeFunc(reshape);
110 glutDisplayFunc(display);
111 glutMouseFunc(mouse);
112 glutMotionFunc(motion);
114 return winid;