Пример #1
0
int main(int argc, char **argv)
{
    OSG::osgInit(argc,argv);
    OSG::PerfMonitor::the()->enable(true);   // Enable performance monitoring

    // GLUT init
    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);

    glutInitWindowSize(500, 500);
    glutCreateWindow("PerfMonitor FG Test");

    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);

    pwin=OSG::PassiveWindow::create();
    pwin->init();

    // create the scene
    OSG::NodeUnrecPtr scene;

    if(argc > 1)
    {
        scene = OSG::Node::create();
        OSG::GroupUnrecPtr g = OSG::Group::create();

        scene->setCore(g);

        for(OSG::UInt16 i = 1; i < argc; ++i)
            scene->addChild(OSG::SceneFileHandler::the()->read(argv[i]));
    }
    else
    {
        scene = OSG::makeTorus(.5, 3, 16, 16);
    }

    // create the SimpleSceneManager helper
    mgr = OSG::SimpleSceneManager::create();

    // create the window and initial camera/viewport
    mgr->setWindow(pwin );
    // tell the manager what to manage
    mgr->setRoot  (scene);

    OSG::Thread::getCurrentChangeList()->commitChanges();

    // show the whole scene
    mgr->showAll();

    // add the statistics forground

    perfmon_fg = OSG::PerfMonitorForeground::create();
    pwin->getPort(0)->addForeground(perfmon_fg);

    //statfg->setMaxSize(25);
    //statfg->setColor(Color4f(0,1,0,0.7));

    act = OSG::RenderAction::create();
    mgr->setAction(act);

    // GLUT main loop
    glutMainLoop();

    return 0;
}
void OpenSGWidget::initializeGL()
{
    pwin->init();   
}