static void crutInitProxy(char *mothership) { char response[8096]; char **newserver; char* server; int mtu; crutInitAPI(&crut_api, mothership); crMothershipIdentifyCRUTProxy( crut_api.mothershipConn, response ); crMothershipGetCRUTServer( crut_api.mothershipConn, response ); newserver = crStrSplit(response, " "); server = newserver[1]; mtu = crMothershipGetMTU(crut_api.mothershipConn); /* set up the connection to recv on */ crut_proxy.recv_conn = crNetConnectToServer( server, DEFAULT_CRUT_PORT, mtu, 1 ); crutConnectToClients( &crut_api ); }
static void crutInitServer(char *mothership, int argc, char *argv[]) { char response[8096]; #ifndef WINDOWS int drawable; #endif int displayMode; crNetInit( NULL/*crutServerRecv*/, crutServerClose ); crutInitAPI( &crut_api, mothership ); /* here? */ crMothershipIdentifyCRUTServer( crut_api.mothershipConn, response ); crutGetWindowParams( &crut_api ); /* set up GLUT window */ glutInit(&argc, argv); displayMode = GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA; if (crut_api.compositeAlpha) displayMode |= GLUT_ALPHA; if (crut_api.compositeDepth) displayMode |= GLUT_STENCIL; glutInitDisplayMode(displayMode); glutInitWindowPosition( crut_api.winX,crut_api.winY ); glutInitWindowSize( crut_api.winWidth,crut_api.winHeight ); glutCreateWindow("CRUTServer Interactive Window"); glutDisplayFunc(showWin); /* give window id to mothership */ #ifndef WINDOWS #ifdef DARWIN /* XXX \todo crut get current drawable (this only gets glut win_num) */ drawable = glutGetWindow(); #else /* XXX is this cast safe? */ drawable = (int) glXGetCurrentDrawable(); #endif crutSetWindowID( &crut_api, drawable); #endif /* use API to connect to clients */ crutConnectToClients( &crut_api ); /* Retrieve events to send out */ crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_mouse", response ); crut_server.callbacks.mouse = crStrToInt(response); crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_keyboard", response ); crut_server.callbacks.keyboard = crStrToInt(response); crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_motion", response ); crut_server.callbacks.motion = crStrToInt(response); crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_passivemotion", response ); crut_server.callbacks.passivemotion = crStrToInt(response); crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_reshape", response ); crut_server.callbacks.reshape = crStrToInt(response); crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_visibility", response ); crut_server.callbacks.visibility = crStrToInt(response); crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_menu", response ); crut_server.callbacks.menu = crStrToInt(response); /* Exit flag */ crMothershipGetCRUTServerParam( crut_api.mothershipConn, response, "exit_on_escape"); crut_server.exit_on_escape = crStrToInt(response); #ifdef USE_CRUT_MENUS crutGetMenuXML(); buildMenu(); #endif }