[osg-users] mygui integration (for Wang Rui)

Denis Colesnicov eugustus at gmail.com
Tue Dec 27 11:11:35 PST 2016


Hi,
 I still do not understand. I'm just getting started with OSG and therefore me a lot of things about escapes. I keep showing either no GUI. My wrapper MyGUI is osgRecipies. Here is my code of the main features:


Code:


int main( int argc, char **argv )
{
    glutInit(&argc, argv);

    osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFile(CREATE_PATH(assets/robot.osg));
    if (!loadedModel)
    {
        std::cout "No data loaded." << std::endl;
        return 1;
    }

    glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_ALPHA );
    glutInitWindowPosition( 100, 100 );
    glutInitWindowSize( 800, 600 );
    glutCreateWindow( argv[0] );
    glutDisplayFunc( display );
    glutReshapeFunc( reshape );
    glutMouseFunc( mousebutton );
    glutMotionFunc( mousemove );
    glutKeyboardFunc( keyboard );



    osg::ref_ptr<osg::Group> root = new osg::Group;

    root->addChild( loadedModel.get() );

    osg::ref_ptr<CustomMYGUIManager> mygui = new CustomMYGUIManager;

    mygui->setResourcePathFile(std::string("/home/denis/Veřejné/Dropbox/Projects/wall/assets/ui/default/resources.xml"));
    osg::ref_ptr<osg::Geode> geode = new osg::Geode;


    geode->setCullingActive( false );
    geode->addDrawable( mygui.get() );
    geode->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON );
    geode->getOrCreateStateSet()->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
    geode->getOrCreateStateSet()->setRenderBinDetails(1000,"RenderBin");

    osg::ref_ptr<osg::Camera> camera = new osg::Camera;
    camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
    camera->setRenderOrder( osg::Camera::POST_RENDER );
    camera->setAllowEventFocus( false );
    camera->setProjectionMatrix( osg::Matrix::ortho2D(0.0, 1.0, 0.0, 1.0) );
    camera->addChild( geode.get() );
    camera->setClearMask(0);

    root->addChild( camera.get() );



    viewer = new osgViewer::Viewer;
    viewer->setSceneData( root.get() );
    viewer->addEventHandler( new MYGUIHandler(camera.get(), mygui.get()) );
    viewer->addEventHandler( new osgViewer::WindowSizeHandler );
    viewer->addEventHandler( new osgViewer::StatsHandler );

    window = viewer->setUpViewerAsEmbeddedInWindow(0,0,800,600);
    viewer->setCameraManipulator(new osgGA::TrackballManipulator);

    viewer->realize();

    glutMainLoop();

    return 0;
}






He knew how would you advise someone please ...

Thanks for google translater ...


Thank you!

Cheers,
Denis

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69778#69778








More information about the osg-users mailing list