Hello Jie Liu,
Jie Liu wrote:
I am using OpenSG v1.8.0,
and I implemented the server/client framework according to the 'Cluster'
chapter of tutorial;
are you using the Tutorials/12ClusterServer.cpp and
Tutorials/13ClusterClient.cpp or did you reimplement them yourself?
I have a problem, that the client window is always black, even though
the server window display a turos;
for the MultiDisplayWindow this is intended, the client runs the
application/simulation/interaction part and the servers produce images
on a tiled display for example.
So how can I show the turos on both server window and client window? I
thank that will be more intuitive for users.
you can give the MultiDisplayWindow a client window that it can use to
render locally (of course that means your client now needs a lot more
resources than before).
BTW, I tried to use setSize/resize method to change window size at
runtime, but seems nothing is took into force.
on the server windows this should work fine (it does for me with the
tutorials), for the client window the reshape callback does not pass the
information to the SimpleSceneManager.
I've attached a modified 13ClusterClient.cpp that renders locally on the
client.
How can I achieve that? And how can I remove the frame border of the
server window?
that depends on the toolkit you use to create the window (e.g. X11,
glut, Qt), with glut I think the best you can do is call glutFullScreen().
Cheers,
Carsten
// OpenSG Tutorial Example: Hello World
//
// Minimalistic OpenSG cluster client program
//
// To test it, run
// ./12ClusterServer -geometry 300x300+200+100 -m -w test1 &
// ./12ClusterServer -geometry 300x300+500+100 -m -w test2 &
// ./13ClusterClient -m -fData/tie.wrl test1 test2
//
// If you have trouble with multicasting, you can alternatively try
// ./12ClusterServer -geometry 300x300+200+100 -w 127.0.0.1:30000 &
// ./12ClusterServer -geometry 300x300+500+100 -w 127.0.0.1:30001 &
// ./13ClusterClient -fData/tie.wrl 127.0.0.1:30000 127.0.0.1:30001
// This will work as long as your loopback interface can handle broadcasts.
// If that is not the case you need to use your local IP address instead
// of 127.0.0.1.
//
// The client will open an emoty window that you can use to navigate. The
// display is shown in the server windows.
//
// This will run all three on the same machine, but you can also start the
// servers anywhere else, as long as you can reach them via multicast.
//
// Note: This will run two VERY active OpenGL programs on one screen. Not all
// OpenGL drivers are happy with that, so if it crashes your X, it's not our
// fault! ;)
// GLUT is used for window handling
#include <OpenSG/OSGGLUT.h>
// General OpenSG configuration, needed everywhere
#include <OpenSG/OSGConfig.h>
// Methods to create simple geometry: boxes, spheres, tori etc.
#include <OpenSG/OSGSimpleGeometry.h>
// The GLUT-OpenSG connection class
#include <OpenSG/OSGGLUTWindow.h>
// A little helper to simplify scene management and interaction
#include <OpenSG/OSGSimpleSceneManager.h>
// The cluster window that handles sort-first (screen-split) clustering
#include <OpenSG/OSGMultiDisplayWindow.h>
// Scene file handler for loading geometry files
#include <OpenSG/OSGSceneFileHandler.h>
// Activate the OpenSG namespace
OSG_USING_NAMESPACE
using namespace std;
// The SimpleSceneManager to manage simple applications
SimpleSceneManager *mgr;
GLUTWindowPtr gwin;
MultiDisplayWindowPtr mwin;
// forward declaration so we can have the interesting stuff upfront
int setupGLUT( int *argc, char *argv[] );
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
char *opt;
NodePtr scene=NullFC;
// OSG init
ChangeList::setReadWriteDefault();
osgInit(argc,argv);
// GLUT init
int winid = setupGLUT(&argc, argv);
// client render window - not used by default
gwin = NullFC;
// the connection between this client and the servers
mwin = MultiDisplayWindow::create();
// all changes must be enclosed in beginEditCP and endEditCP
// otherwise the changes will not be transfered over the network.
beginEditCP(mwin);
// evaluate params
for(int a=1 ; a<argc ; ++a)
{
if(argv[a][0] == '-')
{
switch(argv[a][1])
{
case 'm': mwin->setConnectionType("Multicast");
cout << "Connection type set to Multicast" << endl;
break;
case 'p': mwin->setConnectionType("SockPipeline");
cout << "Connection type set to SockPipeline" << endl;
break;
case 'i': opt = argv[a][2] ? argv[a]+2 : argv[++a];
if(opt != argv[argc])
mwin->setConnectionInterface(opt);
break;
case 'a': opt = argv[a][2] ? argv[a]+2 : argv[++a];
if(opt != argv[argc])
mwin->setServiceAddress(opt);
break;
case 'f': opt = argv[a][2] ? argv[a]+2 : argv[++a];
if(opt != argv[argc])
scene = SceneFileHandler::the().read(
opt,0);
break;
case 'x': opt = argv[a][2] ? argv[a]+2 : argv[++a];
if(opt != argv[argc])
mwin->setHServers(atoi(opt));
break;
case 'y': opt = argv[a][2] ? argv[a]+2 : argv[++a];
if(opt != argv[argc])
mwin->setVServers(atoi(opt));
break;
case 'c':
{
// create a client window for local rendering
gwin = GLUTWindow::create();
}
break;
default: std::cout << argv[0]
<< " -m"
<< " -p"
<< " -c"
<< " -i interface"
<< " -f file"
<< " -x horizontal server cnt"
<< " -y vertical server cnt"
<< endLog;
return 0;
}
}
else
{
printf("%s\n",argv[a]);
mwin->editMFServers()->push_back(argv[a]);
}
}
// dummy size for navigator
mwin->setSize(300, 300);
// end edit of cluster window
endEditCP(mwin);
// setup client render window
if(gwin != NullFC)
{
beginEditCP(gwin);
gwin->setId (winid);
gwin->setSize(300, 300);
endEditCP (gwin);
gwin->init();
beginEditCP(mwin);
mwin->setManageClientViewports(true);
mwin->setClientWindow(gwin);
endEditCP (mwin);
}
// create default scene
if(scene == NullFC)
scene = makeTorus(.5, 2, 16, 16);
// create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// tell the manager what to manage
mgr->setWindow(mwin );
mgr->setRoot (scene);
// show the whole scene
mgr->showAll();
// initialize window
mwin->init();
// GLUT main loop
glutMainLoop();
return 0;
}
//
// GLUT callback functions
//
// redraw the window
void display(void)
{
// redraw the cluster window
mgr->redraw();
// clear change list. If you don't clear the changelist,
// then the same changes will be transmitted a second time
// in the next frame.
OSG::Thread::getCurrentChangeList()->clearAll();
// clear local navigation window
// glClear(GL_COLOR_BUFFER_BIT);
// glutSwapBuffers();
}
// react to size changes
void reshape(int w, int h)
{
mgr ->resize(w, h);
gwin->resize(w, h);
glutPostRedisplay();
}
// react to mouse button presses
void mouse(int button, int state, int x, int y)
{
if (state)
mgr->mouseButtonRelease(button, x, y);
else
mgr->mouseButtonPress(button, x, y);
glutPostRedisplay();
}
// react to mouse motions with pressed buttons
void motion(int x, int y)
{
mgr->mouseMove(x, y);
glutPostRedisplay();
}
// react to keys
void keyboard(unsigned char k, int x, int y)
{
switch(k)
{
case 27:
{
OSG::osgExit();
exit(0);
}
break;
}
}
// setup the GLUT library which handles the windows for us
int setupGLUT(int *argc, char *argv[])
{
glutInit(argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
int winid = glutCreateWindow("OpenSG");
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutIdleFunc(display);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutKeyboardFunc(keyboard);
return winid;
}
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users