rem: cout << "GLUT winid: " << winid << endl;
add: std::cout << "GLUT winid: " << winid << std::endl;
context: int main (int argc, char **argv){    OSG::osgInit(argc,argv);    // GLUT init    glutInit(&argc, argv);    glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);    int winid = glutCreateWindow("OpenSG");    glutKeyboardFunc(key);    glutVisibilityFunc(vis);    glutReshapeFunc(reshape);    glutDisplayFunc(display);           glutMouseFunc(mouse);       glutMotionFunc(motion);         glutIdleFunc(display);      // glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );        glEnable( GL_DEPTH_TEST );    glEnable( GL_LIGHTING );    glEnable( GL_LIGHT0 );    glEnable( GL_NORMALIZE );    glEnable( GL_BLEND);    glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );    // OSG    // create the graph    // beacon for camera and light      OSG::NodePtr b1n = OSG::Node::create();    OSG::GroupPtr b1 = OSG::Group::create();    OSG::beginEditCP(b1n);    b1n->setCore( b1 );    OSG::endEditCP(b1n);    // transformation    OSG::NodePtr t1n = OSG::Node::create();    OSG::TransformPtr t1 = OSG::Transform::create();    OSG::beginEditCP(t1n);    t1n->setCore( t1 );    t1n->addChild( b1n );    OSG::endEditCP(t1n);    cam_trans = t1;    // light        OSG::NodePtr dlight = OSG::Node::create();        dl = OSG::DirectionalLight::create();    OSG::beginEditCP(dlight);    dlight->setCore( dl );    OSG::endEditCP(dlight);        OSG::beginEditCP(dl);    dl->setAmbient( .3, .3, .3, 1 );    dl->setDiffuse( 1, 1, 1, 1 );    dl->setDirection(0,0,1);    dl->setBeacon( b1n);    OSG::endEditCP(dl);    // root    root = OSG::Node::create();    OSG::GroupPtr gr1 = OSG::Group::create();    OSG::beginEditCP(root);    root->setCore( gr1 );    root->addChild( t1n );    root->addChild( dlight );    OSG::endEditCP(root);    // Load the file//    OSG::VRMLFile *pLoader = new OSG::VRMLFile();//    pLoader->scanStandardPrototypes("std.wrl", 0);    for(OSG::UInt32 numFiles = 1; numFiles < argc; numFiles++)    {//        file = FhsFile::load(argv[numFiles]);        file = OSG::SceneFileHandler::the().read(argv[numFiles], 0);/*        pLoader->scanFile(argv[numFiles], OSG::VRMLFile::CreateNormals);        file = pLoader->getRoot();        */                             OSG::beginEditCP(dlight);        dlight->addChild( file );        dlight->invalidateVolume();        OSG::endEditCP(dlight);    }    dlight->updateVolume();    // should check first. ok for now.    const OSG::BoxVolume *vol = (OSG::BoxVolume *)&dlight->getVolume();            OSG::Vec3f min,max;    vol->getBounds( min, max );        cout << "Volume: from " << min << " to " << max << endl;//  cerr << "Tree: " << endl;//    root->print();    // Camera    OSG::PerspectiveCameraPtr cam = OSG::PerspectiveCamera::create();    cam->setBeacon( b1n );    cam->setFov( OSG::deg2rad( 60 ) );    cam->setNear( 0.1 );    cam->setFar( 5000 );    // Solid Background    OSG::SolidBackgroundPtr bkgnd = OSG::SolidBackground::create();    bkgnd->setColor( OSG::Color3f(0,0,1) );    // Viewport    OSG::ViewportPtr vp = OSG::Viewport::create();    vp->setCamera( cam );    vp->setBackground( bkgnd );    vp->setRoot( root );    vp->setSize( 0,0, 1,1 );    // Window    cout << "GLUT winid: " << winid << endl;    OSG::GLUTWindowPtr gwin;    GLint glvp[4];    glGetIntegerv( GL_VIEWPORT, glvp );    gwin = OSG::GLUTWindow::create();    gwin->setId(winid);    gwin->setSize( glvp[2], glvp[3] );    win = gwin;    win->addPort( vp );    // Action        ract = OSG::RenderAction::create();    cerr << "Calculating normals...";        // Task 1: Cal Vertex Normals//  ract->registerEnterFunction( OSG::Geometry::getClassType(),//                                  OSG::osgFunctionFunctor2( calcVNormal ) );    //  ract->apply( dlight );    cerr << "done." << endl;        // Task 2: draw wireframe bbox, if wanted//  ract->registerEnterFunction( OSG::Geometry::getClassType(),//                                  OSG::osgFunctionFunctor2( wireDraw ) );                                        // tball        OSG::Vec3f pos(min[0] + ((max[0] - min[0]) * 0.5),                    min[1] + ((max[1] - min[1]) * 0.5),                    max[2] + ( max[2] - min[2] ) * 1.5 );    OSG::Vec3f cpos(min[0] + ((max[0] - min[0]) * 0.5),                     min[1] + ((max[1] - min[1]) * 0.5),                     min[2] + ((max[2] - min[2]) * 0.5) );    float scale = (max[2] - min[2] + max[1] - min[1] + max[0] - min[0]) / 6;    tball.setMode( OSG::Trackball::OSGObject );    tball.setStartPosition( pos, true );    tball.setSum( true );    tball.setTranslationMode( OSG::Trackball::OSGFree );    tball.setRotationCenter  (cpos);    tball.setTranslationScale(scale);    cam->setFar(fabs(max[2] + ( max[2] - min[2] ) * 3));     if(fabs(max[2] + ( max[2] - min[2] ) * 3) > 1000.f)    {        cam->setNear(10);    }    // run...        glutMainLoop();        return 0;}