changed: gcc8 base update
[opensg.git] / Examples / Tutorial / 14clustering_Server.cpp
blobdecaeea9d2f766d0add0d675d4693e773b587bfc
1 #ifdef OSG_BUILD_ACTIVE
2 #include <OSGGLUT.h>
3 #include <OSGConfig.h>
4 #include <OSGClusterServer.h>
5 #include <OSGGLUTWindow.h>
6 #include <OSGRenderAction.h>
7 #else
8 #include <OpenSG/OSGGLUT.h>
9 #include <OpenSG/OSGConfig.h>
10 #include <OpenSG/OSGClusterServer.h>
11 #include <OpenSG/OSGGLUTWindow.h>
12 #include <OpenSG/OSGRenderAction.h>
13 #endif
15 OSG::GLUTWindowRecPtr window;
16 OSG::RenderActionRefPtr ract;
17 OSG::ClusterServer *server;
19 void display(void);
20 void reshape(int width, int height);
22 int main(int argc,char **argv)
24 int winid;
26 // initialize Glut
27 glutInit(&argc, argv);
28 glutInitDisplayMode( GLUT_RGB |GLUT_DEPTH | GLUT_DOUBLE);
30 if(!argv[1])
32 std::cout << "No name was given!" << std::endl;
33 return -1;
36 // init OpenSG
37 OSG::osgInit(argc, argv);
39 winid = glutCreateWindow(argv[1]);
40 glutDisplayFunc(display);
41 glutIdleFunc(display);
42 glutReshapeFunc(reshape);
43 glutSetCursor(GLUT_CURSOR_NONE);
45 ract = OSG::RenderAction::create();
47 window = OSG::GLUTWindow::create();
48 window->setGlutId(winid);
49 window->init();
51 window->resize(512, 512);
53 //create a new server that will be connected via multicast
54 //argv[1] is the name of the server (at least it should be...)
55 server = new OSG::ClusterServer(window, argv[1], "Multicast", "");
56 server->start();
58 glutMainLoop();
60 return 0;
63 void display(void)
65 //simply execute the render action
66 server->render(ract);
67 //and delete the change list
68 OSG::Thread::getCurrentChangeList()->clear();
71 void reshape(int width, int height)
73 window->resize(width, height);