// 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();

}

OSG多屏显示问题的更多相关文章

  1. 【OSG】将显示的图形窗口化

    窗口化原理 有时为了方便控制场景渲染,需要设置一个合适的图形环境窗口(即窗口化). 创建图形环境的主要步骤如下: (1)通过WindowingSystemInterface类得到系统窗口接口,该系统接 ...

  2. JavaScript:让浏览器全屏显示

    并不是所有人都会按F11让浏览器全屏显示~~~ 一.直接上代码 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xh ...

  3. VMware Tools的简易安装---解决Ubuntu 14.10不能满屏显示问题

    由于使用的VMware WorkStation是中文破解版,安装时又是简易安装,因此VMware Tools并没有安装上,导致Ubuntu 14.10在VMware中装上之后,并不能满屏显示,如图1所 ...

  4. 在VC++6.0开发中实现全屏显示

    全屏显示是一些应用软件程序必不可少的功能.比如在用VC++编辑工程源文件或编辑对话框等资源时,选择菜单“View\Full Screen”,即可进入全屏显示状态,按“Esc”键后会退出全屏显示状态. ...

  5. vim 分屏显示

    我用vim打开一个文件后,想同时打开另一个文件,就像windows中打开两个记事本一样,因此需要分屏显示 首先用vim打开一个文件 vim file1 输入命令[Esc] :sp file2 分屏打开 ...

  6. 转: Eclipse 分屏显示同一个文件

    Eclipse 分屏显示同一个文件   场景 : 某个类很大,可能有数千行.当你想要将类开头部分与中间或者靠后的部分进行对比时,请follow如下步骤: Window -> Editor -&g ...

  7. Android 全屏显示的方法(不包含状态栏)

    我们都知道在Android中某些功能的实现往往有两种方法:一种是在xml文件中设置相应属性,另一种是用代码实现.同样Android实现全屏显示也可以通过这两种方法实现: 1.在AndroidManif ...

  8. c# Winform 开发分屏显示应用程序

    分屏显示即可把一台主机内运行的多个程序分别显示在不同的两个(或多个)屏幕上.目前市面上主流的显卡都支持分屏显示(显示双屏幕),如果需要显示2个以上的屏幕,则应使用“拖机卡”类的硬件. 设置分屏显示的两 ...

  9. Android 全屏显示

    Android全屏显示: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInst ...

随机推荐

  1. asp.net core VS goang web[修正篇]

    先前写过一篇文章:http://www.cnblogs.com/gengzhe/p/5557789.html,也是asp.net core和golang web的对比,热心的园友提出了几点问题,如下: ...

  2. ng-options

    tr td 地点 td select.form-control(required="true" ng-model="addkc.dd" ng-options=& ...

  3. LeetCode_Single Number II

    Given an array of integers, every element appears three times except for one. Find that single one. ...

  4. java交通灯管理系统项目

    交通灯管理系统   模拟实现十字路口的交通灯管理系统逻辑,具体需求如下: 异步随机生成按照各个路线行驶的车辆. 例如: 由南向而来去往北向的车辆 ---- 直行车辆 由西向而来去往南向的车辆 ---- ...

  5. HDU_2053

    Problem Description There are many lamps in a line. All of them are off at first. A series of operat ...

  6. Remove Node in Binary Search Tree 解答

    从BST中移除一个节点是比较复杂的问题,需要分好几种情况讨论. 如这篇文章,就讨论了删除节点 1.有无左右子树 2.只有右子树 3.只有左子树 三种情况. 一种简单些的思维是只考虑删除节点是否有右子树 ...

  7. HDU-1978How many ways

    Problem Description 这是一个简单的生存游戏,你控制一个机器人从一个棋盘的起始点(1,1)走到棋盘的终点(n,m).游戏的规则描述如下:1.机器人一开始在棋盘的起始点并有起始点所标有 ...

  8. [原创+实战+钓鱼]setoolkit+映射

    所需工具:setoolkit,花生壳 (此方法主要针对没有服务器,没有空间的攻击者.有服务器或者空间可以直接上传setoolkit的生成源码到服务器或者空间.) 1.setoolkit克隆一个站点 | ...

  9. (转)苹果消息推送服务器 php 证书生成

    1.准备好 aps_developer_identity.cer , push.p12这两个证书文件 2. 生成证书如下: openssl x509 -in aps_developer_identit ...

  10. (转)命令行下,用 xcodebuild 生成ipa文件,通过 itms-services 协议安装

    准备工作:已经设置好,xcode中的证书,证书必须是企业级证书,才能通过 itms-services 协议安装 Step 1:  把以下代码保存到一个web目录中,命名为 “auto.plist”,注 ...