zoukankan      html  css  js  c++  java
  • OSG多屏显示问题

    // testMultiScreen.cpp : Defines the entry point for the console application.
    //

    #include "stdafx.h"
    #include <osg/Camera>
    #include <osgDB/ReadFile>
    #include <osgGA/TrackballManipulator>
    #include <osgViewer/CompositeViewer>


    osgViewer::View* createView( int screenNum )
    {

     unsigned int width = 800, height = 600;

    //判断了当前是否存在窗体接口
     osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
     if ( wsi )
     wsi->getScreenResolution( osg::GraphicsContext::ScreenIdentifier(screenNum), width, height );
    //创建Traits

     osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
     traits->screenNum = screenNum;
     traits->x = 0;
     traits->y = 0;
     traits->width = width;
     traits->height = height;
     traits->windowDecoration = false;
     traits->doubleBuffer = true;
     traits->sharedContext = 0;

    //创建一个图形上下文

     osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext( traits.get() );
     if ( !gc ) return NULL;
     osg::ref_ptr<osg::Camera> camera = new osg::Camera;
     camera->setGraphicsContext( gc.get() );
     camera->setViewport( new osg::Viewport(0, 0, width, height) );
     camera->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width)/static_cast<double>(height),1.0f, 10000.0f );
     GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
     camera->setDrawBuffer( buffer );
     camera->setReadBuffer( buffer );

     osg::ref_ptr<osgViewer::View> view = new osgViewer::View;
     view->setCamera( camera.get() );
     view->setCameraManipulator( new osgGA::TrackballManipulator );
     return view.release();
    }

    int _tmain(int argc, _TCHAR* argv[])
    {
     osgViewer::CompositeViewer viewer;

     osgViewer::View* view1 = createView( 0 );
     if ( view1 )
     {
      view1->setSceneData( osgDB::readNodeFile("cessna.osg") );
      viewer.addView( view1 );
     }

     osgViewer::View* view2 = createView( 1 );
     if ( view2 )
     {
      view2->setSceneData( osgDB::readNodeFile("cow.osg") );
      viewer.addView( view2 );
     }

     return viewer.run();


    }

  • 相关阅读:
    图论03—随意两点间最短距离及路径(改进)
    &lt;转&gt;Openstack ceilometer 宿主机监控模块扩展
    【从零学习openCV】IOS7下的openCV开发起步(Xcode5.1.1&amp;openCV2.49)
    零基础学python-6.2 共享引用
    hdu 2191 悼念512汶川大地震遇难同胞——珍惜如今,感恩生活
    Android与设计模式——单例(Singleton)模式
    SpringMVC+Jquery -页面异步载入数据
    hdoj Let the Balloon Rise
    openStack使用宿主机监控
    winscp自动执行脚本
  • 原文地址:https://www.cnblogs.com/blogofwu/p/4900830.html
Copyright © 2011-2022 走看看