当前位置: 首页>>代码示例>>C++>>正文


C++ osg::GLUTWindowRecPtr类代码示例

本文整理汇总了C++中osg::GLUTWindowRecPtr的典型用法代码示例。如果您正苦于以下问题:C++ GLUTWindowRecPtr类的具体用法?C++ GLUTWindowRecPtr怎么用?C++ GLUTWindowRecPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GLUTWindowRecPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
    OSG::osgInit(argc,argv);
    
    {
        int winid = setupGLUT(&argc, argv);
        OSG::GLUTWindowRecPtr gwin = OSG::GLUTWindow::create();
        gwin->setGlutId(winid);
        gwin->init();
    
        scene =createScenegraph();
    
        mgr = new OSG::SimpleSceneManager;
        mgr->setWindow(gwin );
        mgr->setRoot  (scene);
        mgr->showAll();
        
        OSG::Navigator * nav = mgr->getNavigator();
        nav->setFrom(nav->getFrom()+OSG::Vec3f(0,50,0));
        
        OSG::commitChanges();
    }
    
    glutMainLoop();

    return 0;
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:27,代码来源:09geometry_water3.cpp

示例2: main

int main(int argc, char **argv)
{
    OSG::osgInit(argc,argv);

    {
        int winid = setupGLUT(&argc, argv);
        OSG::GLUTWindowRecPtr gwin = OSG::GLUTWindow::create();
        gwin->setGlutId(winid);
        gwin->init();

        if (argc > 1)
            scene = createScenegraph(argv[1]);
        else
            scene = createScenegraph("Data/brick_quads.wrl");

        mgr = new OSG::SimpleSceneManager;
        mgr->setWindow(gwin );
        mgr->setRoot  (scene);
        mgr->showAll();

        OSG::commitChanges();
    }

    glutMainLoop();

    return 0;
}
开发者ID:rdgoetz,项目名称:OpenSGDevMaster_Toolbox,代码行数:27,代码来源:12traversal2.cpp

示例3: main

int main(int argc, char **argv)
{
    OSG::osgInit(argc,argv);
    
    {
        int winid = setupGLUT(&argc, argv);
        OSG::GLUTWindowRecPtr gwin = OSG::GLUTWindow::create();
        gwin->setGlutId(winid);
        gwin->init();
    
        scene = createScenegraph();
    
        mgr = OSG::SimpleSceneManager::create();
        mgr->setWindow(gwin );
        mgr->setRoot  (scene);
        mgr->showAll();
        
        OSG::commitChanges();
    }
    
    glutMainLoop();

    return 0;
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:24,代码来源:08coresdemo1.cpp

示例4: main

int main(int argc, char *argv[])
{
    // Init the OpenSG subsystem
    OSG::osgInit(argc, argv);

    {
        // We create a GLUT Window (that is almost the same for most applications)
        int winid = setupGLUT(&argc, argv);
        OSG::GLUTWindowRecPtr gwin = OSG::GLUTWindow::create();
        gwin->setGlutId(winid);
        gwin->init();

        // Create the face
        std::string family = "SANS";
        OSG::TextFace::Style style = OSG::TextFace::STYLE_PLAIN;
        OSG::TextTXFParam txfParam;
        txfParam.size = 46;
        txfParam.gap = 1;
        txfParam.setCharacters("Hello World!");
        txfParam.textureWidth = 0;
        OSG::TextTXFFaceRefPtr face =
            OSG::TextTXFFace::create(family, style, txfParam);
        if (face == 0)
        {
            std::cerr << "ERROR: Cannot create face object!" << std::endl;
            return -1;
        }

        // Lay out one single line of text
        std::string text = "Hello World!"; // Use UTF-8 encoding!
        OSG::TextLayoutParam layoutParam;
        layoutParam.horizontal = true;
        layoutParam.leftToRight = true;
        layoutParam.topToBottom = true;
        layoutParam.majorAlignment = OSG::TextLayoutParam::ALIGN_FIRST;
        layoutParam.minorAlignment = OSG::TextLayoutParam::ALIGN_FIRST;
        layoutParam.spacing = 1.f;
        layoutParam.length.push_back(0.f);
        layoutParam.maxExtend = 0.f;
        OSG::TextLayoutResult layoutResult;
        face->layout(text, layoutParam, layoutResult);

        // Create the text geometry
        OSG::Real32 scale = 1.f;
        OSG::NodeRecPtr scene = face->makeNode(layoutResult, scale);

        // Get the texture that contains the characters of the font
        OSG::ImageRecPtr image = face->getTexture();

        // Create the texture that will hold the image
        OSG::SimpleTexturedMaterialRecPtr tex =
            OSG::SimpleTexturedMaterial::create();
        tex->setImage(image);
        tex->setEnvMode(GL_MODULATE);
        tex->setDiffuse(OSG::Color3f(1, 0, 0));

        // Assign the texture to the geometry
        OSG::GeometryRecPtr geo =
            dynamic_cast<OSG::Geometry *>(scene->getCore());
        geo->setMaterial(tex);

        // Create and setup the SSM
        mgr = new OSG::SimpleSceneManager;
        mgr->setWindow(gwin);
        mgr->setRoot(scene);

        // Create a blue background
        OSG::SolidBackgroundRecPtr bg = OSG::SolidBackground::create();
        bg->setColor(OSG::Color3f(0.1, 0.1, 0.5));

        gwin->getPort(0)->setBackground(bg);

        mgr->showAll();

        OSG::commitChanges();
    }

    // Give Control to the GLUT Main Loop
    glutMainLoop();

    return 0;
}
开发者ID:rdgoetz,项目名称:OpenSGDevMaster_Toolbox,代码行数:82,代码来源:16text_txf.cpp

示例5: main

int main(int argc, char *argv[])
{
    // Init the OpenSG subsystem
    OSG::osgInit(argc, argv);

    {
        // We create a GLUT Window (that is almost the same for most applications)
        int winid = setupGLUT(&argc, argv);
        OSG::GLUTWindowRecPtr gwin = OSG::GLUTWindow::create();
        gwin->setGlutId(winid);
        gwin->init();
    
        // Create the face
        std::string family = "SANS";
        OSG::TextFace::Style style = OSG::TextFace::STYLE_PLAIN;
        OSG::UInt32 size = 32;
        OSG::TextPixmapFaceRefPtr face = 
            OSG::TextPixmapFace::create(family, style, size);
        if (face == 0)
        {
            std::cerr << "ERROR: Cannot create face object!" << std::endl;
            return -1;
        }
    
        // Lay out one single line of text
        std::string text = "Hello World!"; // Use UTF-8 encoding!
        OSG::TextLayoutParam layoutParam;
        layoutParam.horizontal = true;
        layoutParam.leftToRight = true;
        layoutParam.topToBottom = true;
        layoutParam.majorAlignment = OSG::TextLayoutParam::ALIGN_FIRST;
        layoutParam.minorAlignment = OSG::TextLayoutParam::ALIGN_FIRST;
        layoutParam.spacing = 1.f;
        layoutParam.length.push_back(0.f);
        layoutParam.maxExtend = 0.f;
        OSG::TextLayoutResult layoutResult;
        face->layout(text, layoutParam, layoutResult);
    
        // Render the text into an OpenSG image
        OSG::Vec2f offset;
        OSG::UInt32 border = 1;
        OSG::ImageRecPtr imagePtr = face->makeImage(layoutResult, offset, border);
        
        // Create the geometry which we will assign the texture to
        OSG::Real32 width = imagePtr->getWidth();
        OSG::Real32 height = imagePtr->getHeight();
        OSG::NodeRecPtr plane = OSG::makePlane(width, height, 1, 1);
    
        // Create the texture that will hold the image
        OSG::SimpleTexturedMaterialRecPtr tex = 
            OSG::SimpleTexturedMaterial::create();
        tex->setImage(imagePtr);
        tex->setEnvMode(GL_MODULATE);
        tex->setDiffuse(OSG::Color3f(1, 0, 0));
    
        // Assign the texture to the geometry
        OSG::GeometryRecPtr geo =
            dynamic_cast<OSG::Geometry *>(plane->getCore());
        geo->setMaterial(tex);
    
        // Transform the geometry so that the origin of the text is at
        // the origin of the world coordinate system
        OSG::NodeRecPtr scene = OSG::Node::create();
        OSG::TransformRecPtr transformPtr = OSG::Transform::create();
        OSG::Matrix m;
        m.setTranslate(offset.x() + width / 2, offset.y() - height / 2, 0);
        transformPtr->setMatrix(m);
        
        scene->setCore(transformPtr);
        scene->addChild(plane);
        
        // Create and setup the SSM
        mgr = new OSG::SimpleSceneManager;
        mgr->setWindow(gwin);
        mgr->setRoot(scene);
    
        // Create a blue background
        OSG::SolidBackgroundRecPtr bg = OSG::SolidBackground::create();
        bg->setColor(OSG::Color3f(0.1, 0.1, 0.5));
        
        gwin->getPort(0)->setBackground(bg);
        
        mgr->showAll();
        
        OSG::commitChanges();
    }

    // Give Control to the GLUT Main Loop
    glutMainLoop();

    return 0;
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:92,代码来源:16text_pixmap.cpp

示例6: motion

void motion(int x, int y)
{
    OSG::Real32 w = clientWindow->getWidth(), h = clientWindow->getHeight();


    OSG::Real32 a = -2. * ( lastx / w - .5 ),
                b = -2. * ( .5 - lasty / h ),
                c = -2. * ( x / w - .5 ),
                d = -2. * ( .5 - y / h );

    if ( mouseb & ( 1 << GLUT_LEFT_BUTTON ) )
    {
        tball.updateRotation( a, b, c, d );
    }
    else if ( mouseb & ( 1 << GLUT_MIDDLE_BUTTON ) )
    {
        tball.updatePosition( a, b, c, d );
    }
    else if ( mouseb & ( 1 << GLUT_RIGHT_BUTTON ) )
    {
        tball.updatePositionNeg( a, b, c, d );
    }
    lastx = x;
    lasty = y;
	glutPostRedisplay();
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:26,代码来源:testClusterClient.cpp

示例7: doMain

// Initialize GLUT & OpenSG and set up the scene
int doMain(int argc, char **argv)
{
    std::cout << "start a cluster server with './testClusterServer -w pipe0'\n"
                 "press 'c' to connect to the servers.\n"
                 "press 'd' to disconnect from the servers.\n"
                 "press 'n' to delete current scene.\n"
                 "press 't' to create a torus.\n"
                 "press 'l' to load scene 'tie.wrl'.\n"
              << std::endl;
    
    // OSG init
    OSG::osgInit(argc,argv);

    OSG::VTKPolyDataMapper::getClassType().dump();

    // GLUT init
    int winid = setupGLUT(&argc, argv);

    // the connection between GLUT and OpenSG

    _client_win = OSG::GLUTWindow::create();

    _client_win->setGlutId(winid);
    _client_win->init();
    _client_win->setSize(300,300);
    
    for(OSG::Int32 i=0;i<argc-1;++i)
    {
        if(argv[i+1] != NULL)
            _pipenames.push_back(argv[i+1]);
    }

    if(_pipenames.empty())
        _pipenames.push_back("pipe0");
    
    _root = OSG::Node::create();
    
    _root->setCore(OSG::Group::create());
    
    // create default scene
//    NodePtr scene = makeTorus(.5, 2, 16, 16);
    OSG::NodeUnrecPtr scene = initVTK();

    _root->addChild(scene);

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

    // tell the manager what to manage
    _mgr->setWindow(_client_win );
    _mgr->setRoot  (_root);

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

    return 0;
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:59,代码来源:testVTKClusterConnect.cpp

示例8: key

void key(unsigned char key, int /*x*/, int /*y*/)
{
	switch ( key )
	{
        case 'd':
            window->getPort(0)->getRoot()->dump();
            break;
        case 's':
            OSG::SceneFileHandler::the()->write(
                window->getPort(0)->getRoot(),"server.osg");
            cleanup();
            exit(0);
            break;
	}
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:15,代码来源:appClusterServerGLUT.cpp

示例9: reshape

void reshape( int width, int height )
{
    winWidth  = width;
    winHeight = height;
    std::cout << "reshape " << width << " " << height << std::endl;
	window->resize( width, height );
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:7,代码来源:appClusterServerGLUT.cpp

示例10: reshape

void reshape( int width, int height )
{
    printf("reshape %d %d\n",width,height);
    glViewport(0, 0, width, height);

	clientWindow->resize( width, height );

	glutPostRedisplay();
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:9,代码来源:testClusterClient.cpp

示例11: main

int main(int argc,char **argv)
{
    int winid;

    // initialize Glut
    glutInit(&argc, argv);
    glutInitDisplayMode( GLUT_RGB |GLUT_DEPTH | GLUT_DOUBLE);

    if(!argv[1])
    {
        std::cout << "No name was given!" << std::endl;
        return -1;
    }
    
    // init OpenSG
    OSG::osgInit(argc, argv);

    winid = glutCreateWindow(argv[1]);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutReshapeFunc(reshape);
    glutSetCursor(GLUT_CURSOR_NONE);

    ract = OSG::RenderAction::create();

    window = OSG::GLUTWindow::create();
    window->setGlutId(winid);
    window->init();

    window->resize(512, 512);

    //create a new server that will be connected via multicast
    //argv[1] is the name of the server (at least it should be...)
    server = new OSG::ClusterServer(window, argv[1], "StreamSock", "");
    server->start();

    glutMainLoop();

    return 0;
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:40,代码来源:14clusteringStream_Server.cpp

示例12: display

void display()
{
    if(!running)
    {
        server->start();
        running=true;
        glutShowWindow();
    }
    /*! ignore rendering in zero sized windows */
    if(!winWidth || !winHeight)
        return;
    try
    {                                                       
        OSG::FrameHandler::the()->frame();
        OSG::commitChanges();
        server->render(ract);
        // clear changelist from prototypes
        OSG::Thread::getCurrentChangeList()->clear();
    } 
    catch(OSG_STDEXCEPTION_NAMESPACE::exception &e)
    {
        if(exitOnError)
        {
            SLOG << e.what() << std::endl;
            printf("Exit on error %s",e.what());
            try
            {
                cleanup();
            }

            catch(...)
            {
            }

            exit(0);
        }
        else
        {
            window->clearPorts();
            // try to restart server
            try
            {
                server->stop();
            }
            catch(...)
            {
            }
            running=false;
            glutHideWindow();
        }
    }
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:52,代码来源:appClusterServerGLUT.cpp

示例13: reshape

// react to size changes
void reshape(int w, int h)
{
    if(glutGetWindow() == mainwinid)
    {
        mgr->resize(w,h);
        glutPostRedisplay();
    }
    else if(glutGetWindow() == debugwinid)
    {
        debugwin->resize(w,h);
        glutPostRedisplay();       
    }
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:14,代码来源:testOcclusionCulling.cpp

示例14: connectCluster

static void connectCluster(void)
{
    if(_cluster_win != NULL)
        return;

    OSG::Viewport *clientvp = _client_win->getPort(0);
    
    // create the viewports for the cluster just a simple one ...
    OSG::ViewportUnrecPtr vp = OSG::Viewport::create();

    vp->setCamera    (_mgr->getCamera());
    vp->setBackground(clientvp->getBackground());
    vp->setRoot      (clientvp->getRoot());
    vp->setSize      (0,0, 1,1);

    // the connection between this client and the servers
    _cluster_win = OSG::MultiDisplayWindow::create();

    // all changes must be enclosed in beginEditCP and endEditCP
    // otherwise the changes will not be transfered over the network.

    for(OSG::UInt32 i=0;i<_pipenames.size();++i)
        _cluster_win->editMFServers()->push_back(_pipenames[i]);
    // dummy size for navigator
    _cluster_win->setSize(300,300);
    _cluster_win->addPort(vp);

    OSG::Thread::getCurrentChangeList()->commitChangesAndClear();
    OSG::Thread::getCurrentChangeList()->fillFromCurrentState();
    OSG::Thread::getCurrentChangeList()->dump();
    // create from the current state a changelist.

    // initialize window
    _cluster_win->init();

    // apply changelist to the servers
    _cluster_win->render((OSG::RenderAction *) _mgr->getRenderAction());

    // clear changelist
    OSG::Thread::getCurrentChangeList()->clear();

    glutPostRedisplay();
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:43,代码来源:testVTKClusterConnect.cpp

示例15: reshape

void reshape(int width, int height)
{
    window->resize(width, height);
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:4,代码来源:14clustering_Server.cpp


注:本文中的osg::GLUTWindowRecPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。