• OSG_EXAMPLE:osgwindows[创建窗口]


    int main(int argc, char** argv)
    {
        osg::ArgumentParser arguments(&argc, argv);
        
        osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
    
        std::string path = osgDB::getFilePath("");
    
        if(!loadedModel) 
            loadedModel = osgDB::readRefNodeFile("");
    
        if(!loadedModel)
        {
            std::cout << arguments.getApplicationName() << std::endl;
            return 1;
        }
    
        osgViewer::Viewr viewer;
        
        int xoffset = 40;
        int yoffset  = 40;
    
        // left window + left slave camera
        {
            osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
    
            traits->x = xoffset + 0;
            traits->y = yoffset + 0;
            traits->width = 600;
            traits->height = 480;
            traits->windowDecoration = true;
            traits->doubleBuffer = true;
            traits->sharedContext = 0;
            traits->readDISPLAY();
            traits->setUndefinedScreenDetailsToDefaultScreen();
    
            osg::ref_ptr<osg::GraphicsContext> gc = 
                    osg::GraphicsContext::createGraphicsContext(traits.get());
        
            osg::ref_ptr<osg::Camera> camera = new osg::Camera;
            camera->setGraphicsContext(gc.get());
            camera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
    
            GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
            camera->setDrawBuffer(buffer);
            camera->setReadBuffer(buffer);
    
            viewer.addSlave(camera.get(), osg::Matrixd::translate(1.0, 0.0, 0.0), osg::Matrixd());
        }
    
        // right window + right slave camera
        {
            osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
            traits->x = xoffset + 600;
            traits->y = yoffset + 0;
            traits->width = 600;
            traits->height = 480;
            traits->windowDecoration = true;
            traits->doubleBuffer = true;
            traits->sharedContext = 0;    
            traits->readDISPLAY();
            traits->setUndefinedScreenDetailsToDefaultScreen();
    
            osg::ref_ptr<osg::GraphicsContext> gc 
                = osg::GraphicsContext::createGraphicsContext(traits.get());
    
            osg::ref_ptr<osg::Camera> camear = new osg::Camera;
            camera->setGraphicsContext(gc.get());
            camera->setViewport(new osg::Viewport(0.0, traits->width, traits->height));
            GLenum buffer = traits->doubleBuffer ? GL_BACK :GL_FRONT;
            camera->setDrawBuffer(buffer);
            camera->setReadBuffer(buffer);
    
            viewer.addSlave(camear.get(), osg::Matrixd::translate(-1.0, 0.0, 0.0), osg::Matrixd());
        }
    
        osgUtil::Optimizer optimizer;
        optimizer.optimize(loadedmodel);
    
        viewer.setSceneDat(loadedModel);
    
        return viewer.run();
    }
  • 相关阅读:
    CodeForces
    4.15随笔
    oracle新建用户并赋予权限等
    catch时,获取异常信息
    ORACLE 判断是否为数字类型
    UNION ALL用法
    2019.11.7随笔
    oracle 查询锁表和解锁
    2019.11.1随笔
    oracle拼接子查询返回的多个结果
  • 原文地址:https://www.cnblogs.com/k5bg/p/13098267.html
Copyright © 2020-2023  润新知