void display(void)
{
    OSG::Matrix m1;

    // Anim
    OSG::Real32 t = glutGet(GLUT_ELAPSED_TIME);
    m1.setTransform(-sceneTrans, OSG::Quaternion(OSG::Vec3f(0,1,0), 
                                                 t / 1000.f));
    sceneXform->setMatrix(m1);

    OSG::commitChanges();

    mgr->redraw();

    // all done, swap
    glutSwapBuffers();

    if(bReadBack == true)
    {
        OSG::Image *pImg = tx1o->getImage();
        
        pImg->write("/tmp/foo.png");
    }
}
void key(unsigned char key, int x, int y)
{
    switch(key)
    {
        case 27:

            planeRoot      = static_cast<OSG::Node *>(NULL);
            animRoot       = static_cast<OSG::Node *>(NULL);

            cam_transScene = static_cast<OSG::Node *>(NULL);
            sceneXform     = static_cast<OSG::Node *>(NULL);

            tx1o           = NULL;
            tx1e           = NULL;

#ifdef USE_DEPTH_TEXTURE
            txDepth        = NULL;
#endif

            pFBO           = NULL;
            pTexBuffer     = NULL;

            pVisit         = static_cast<OSG::Node *>(NULL);

            mgr            = NULL;

            OSG::osgExit();
            exit(0);

        case 'a':
            glDisable( GL_LIGHTING );
            std::cerr << "Lighting disabled." << std::endl;
            break;
        case 's':
            glEnable( GL_LIGHTING );
            std::cerr << "Lighting enabled." << std::endl;
            break;
        case 'z':
            glPolygonMode( GL_FRONT_AND_BACK, GL_POINT);
            std::cerr << "PolygonMode: Point." << std::endl;
            break;
        case 'x':
            glPolygonMode( GL_FRONT_AND_BACK, GL_LINE);
            std::cerr << "PolygonMode: Line." << std::endl;
            break;
        case 'c':
            glPolygonMode( GL_FRONT_AND_BACK, GL_FILL);
            std::cerr << "PolygonMode: Fill." << std::endl;
            break;
        case 'd':
            std::cerr << "Wrote out scene file." << std::endl;
            OSG::SceneFileHandler::the()->write(planeRoot, 
                                                "simple_stage_dump.osb");
            break;
        case 'b':
            bBoxActive = !bBoxActive;

            if(bBoxActive == true)
            {
                pVisit->setSubTreeTravMask(0xFFFFFFFF);
            }
            else
            {
                pVisit->setSubTreeTravMask(0xFFFFFFFE);
            }
            break;

        case 'B':
        {
            OSG::ImageRefPtr pImg = tx1o->getImage();

            pImg->set(OSG::Image::OSG_RGB_PF, 512, 512);

//            tx1o->imageContentChanged();

//            Window::reinitializeGLObject(tx1o->getGLId());

            pFBO->setSize(512, 512);
        }
        break;

        case 'S':
        {
            OSG::ImageRefPtr pImg = tx1o->getImage();
            
            pImg->set(OSG::Image::OSG_RGB_PF, 256, 256);

//            tx1o->imageContentChanged();

//            Window::reinitializeGLObject(tx1o->getGLId());

            pFBO->setSize(256, 256);
        }
        break;
        
        case 'r':
        {
            fprintf(stderr, "enable readback\n");

            bReadBack = true;

            pFBO->setPostProcessOnDeactivate(true);
        }
        break;

        case 'R':
        {
            fprintf(stderr, "disable readback\n");

            bReadBack = false;

            pFBO->setPostProcessOnDeactivate(false);
        }

    }
}