rem: cout << "Create SimpleMaterial" << endl;
add: std::cout << "Create SimpleMaterial" << std::endl;
context: int main (int argc, char **argv){    osgInit(argc,argv);    // GLUT init    glutInit(&argc, argv);    glutInitDisplayMode( GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);    int winid = glutCreateWindow("OpenSG");    glutKeyboardFunc(key);    glutVisibilityFunc(vis);    glutReshapeFunc(reshape);    glutDisplayFunc(display);    glutIdleFunc(display);    glutMouseFunc(mouse);    glutMotionFunc(motion);    glutIdleFunc(display);    // glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );    glEnable( GL_DEPTH_TEST );    glEnable( GL_LIGHTING );    glEnable( GL_LIGHT0 );    // OSG    // create the graph    // beacon for camera and light    NodePtr b1n = Node::create();    GroupPtr b1 = Group::create();    beginEditCP(b1n);    b1n->setCore( b1 );    endEditCP(b1n);    // transformation    NodePtr t1n = Node::create();    TransformPtr t1 = Transform::create();    beginEditCP(t1n);    t1n->setCore( t1 );    t1n->addChild( b1n );    endEditCP(t1n);    cam_trans = t1;    // light    NodePtr dlight = Node::create();    DirectionalLightPtr dl = DirectionalLight::create();    beginEditCP(dlight);    dlight->setCore( dl );    endEditCP(dlight);    beginEditCP(dl);    dl->setAmbient( .3, .3, .3, 1 );    dl->setDiffuse( 1, 1, 1, 1 );    dl->setDirection(0,0,1);    dl->setBeacon( b1n);    endEditCP(dl);    // root    root = Node::create();    GroupPtr gr1 = Group::create();    beginEditCP(root);    root->setCore( gr1 );    root->addChild( t1n );    root->addChild( dlight );    endEditCP(root);    // create the slice node        slicesCore = Slices::create();    NodePtr slicesNode = Node::create();    beginEditCP(slicesNode);    slicesNode->setCore(slicesCore);    endEditCP(slicesNode);    Image *imageP = 0;    Vec3f size;    if (argc > 1)       {        imageP = new Image();        if (imageP->read(argv[1]))          {            if (imageP->getFrameCount() > 1)               imageP->flipDepthFrameData();            size.setValues( imageP->getWidth(),                             imageP->getHeight(),                             imageP->getDepth() );            imageP->dump();            imageP->scaleNextPower2();            if (imageP->hasAlphaChannel() == false) {              switch (imageP->getPixelFormat()) {              case Image::OSG_L_PF:                imageP->reformat(Image::OSG_LA_PF);                break;              case Image::OSG_RGB_PF:                imageP->reformat(Image::OSG_RGBA_PF);                break;              default:                cerr << "Can not reformat image\n" << endl;                break;              }            }            imageP->dump();          }        else          {            FFATAL (("Can not read \'%s\'\n", argv[1]));            delete imageP;            imageP = 0;            return -1;          }      }    MaterialPtr matPtr;        if (imageP)       {        cout << "Create ChunkMaterial" << endl;        ChunkMaterialPtr  texMatPtr     = ChunkMaterial::create();        TextureChunkPtr   texChunkPtr   = TextureChunk::create();        BlendChunkPtr     blendChunkPtr = BlendChunk::create();        beginEditCP (texChunkPtr);        {          texChunkPtr->setImage     ( imageP);          texChunkPtr->setWrapS     ( GL_CLAMP );          texChunkPtr->setWrapT     ( GL_CLAMP );          texChunkPtr->setWrapR     ( GL_CLAMP );          texChunkPtr->setMinFilter ( GL_LINEAR );          texChunkPtr->setMagFilter ( GL_LINEAR );          //texChunkPtr->setMinFilter ( GL_NEAREST );          //texChunkPtr->setMagFilter ( GL_NEAREST );        }        endEditCP   (texChunkPtr);        beginEditCP (blendChunkPtr);        {          blendChunkPtr->setSrcFactor  ( GL_SRC_ALPHA           );          blendChunkPtr->setDestFactor ( GL_ONE_MINUS_SRC_ALPHA );        }        endEditCP   (blendChunkPtr);        beginEditCP (texMatPtr);        {          texMatPtr->addChunk(texChunkPtr);          texMatPtr->addChunk(blendChunkPtr);        }        endEditCP   (texMatPtr);        matPtr = texMatPtr;        //numberOfSlices = unsigned((size.x() + size.y() + size.z()) / 3);        numberOfSlices = unsigned(size.length());        size.normalize();      }    else       {        cout << "Create SimpleMaterial" << endl;        SimpleMaterialPtr colMatPtr = SimpleMaterial::create();        beginEditCP (colMatPtr);        {          colMatPtr->setDiffuse( Color3f( 1,0,0 ) );          colMatPtr->setAmbient( Color3f( 1,0,0 ) );          colMatPtr->setSpecular( Color3f( 1,1,1 ) );          colMatPtr->setShininess( 10 );        }        endEditCP   (colMatPtr);        matPtr = colMatPtr;        size.setValues(1,1,1);        numberOfSlices = 10;      }        cout << size << endl;    cout << numberOfSlices << endl;        beginEditCP(slicesCore);    {      slicesCore->setMaterial       (matPtr);      slicesCore->setSize           (size);      slicesCore->setNumberOfSlices (numberOfSlices);    }    endEditCP(slicesCore);        slicesNode->updateVolume();        Vec3f min,max;    slicesNode->getVolume().getBounds( min, max );        cout << "Volume: from " << min << " to " << max << endl;        beginEditCP(dlight);    dlight->addChild( slicesNode );    endEditCP(dlight);    // Camera    cam = PerspectiveCamera::create();    cam->setBeacon( b1n );    cam->setFov( deg2rad( 45 ) );    cam->setNear( 0.1 );    cam->setFar( 10000 );    // Background    SolidBackgroundPtr bkgnd = SolidBackground::create();    // Viewport    vp = Viewport::create();    vp->setCamera( cam );    vp->setBackground( bkgnd );    vp->setRoot( root );    vp->setSize( 0,0, 1,1 );    // Window    cout << "GLUT winid: " << winid << endl;    GLUTWindowPtr gwin;    GLint glvp[4];    glGetIntegerv( GL_VIEWPORT, glvp );    glCullFace (GL_BACK);    gwin = GLUTWindow::create();    gwin->setId(winid);    gwin->setSize( glvp[2], glvp[3] );    win = gwin;    win->addPort( vp );    win->init();    // Action    ract = DrawAction::create();    // tball    // navigation speed    Vec3f dim(max - min);    cout << "dim: " << dim.length() << endl;    navigator.set( Pnt3f ( dim.length() * 2, 0, 0),                   Pnt3f ( 0,0,0),                   Vec3f ( 0,1,0) );    navigator.setMotionFactor ( dim.length() * 0.1 );    navigator.setMode(Navigator::TRACKBALL);    navigator.setViewport(vp);    // run...    glutMainLoop();    return 0;}