• [osg]osg窗口显示和单屏幕显示


    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("cow.osg");
     osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
     {
      osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
      traits->x = 40;
      traits->y = 40;
      traits->width = 600;
      traits->height = 480;
      traits->windowDecoration = true;
      traits->doubleBuffer = true;
      traits->sharedContext = 0;
    
      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);
    
      // add this slave camera to the viewer, with a shift left of the projection matrix
      viewer->addSlave(camera.get());
     }
     osgUtil::Optimizer optimizer;
     optimizer.optimize(loadedModel.get());
     viewer->setSceneData(loadedModel.get());
    
    //viewer->setUpViewOnSingleScreen(0);//这里是单屏幕显示
     
     return viewer->run();
    

      

  • 相关阅读:
    Activity的生命周期和启动模式
    网络基础1
    Jersey用户指南学习笔记1
    IntelliJ IDEA + Maven + Jetty + Jersey搭建RESTful服务
    Java并发编程实战笔记—— 并发编程4
    Java并发编程实战笔记—— 并发编程3
    Java并发编程实战笔记—— 并发编程2
    7.2.4
    7.2.4
    7.2.3
  • 原文地址:https://www.cnblogs.com/lyggqm/p/8202781.html
Copyright © 2020-2023  润新知