// 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. 【创建型】Singleton模式

    单例模式可以说是所有23种设计模式中最为简单的一个,没有之一.其主要思想就是保证整个应用环境中,最多只会有一个对象的实例.类关系图参考如下: 在c++中,单例模式的实现,较为常用的实现方式一般为: n ...

  2. IE11新特性 -- Internet Explorer 11:请不要再叫我IE

    Internet Explorer 11 中的一些新特性,包括对WebGL 的支持.预抓取.预渲染.flexbox.mutationobservers 以及其他一些 Web 标准的支持.但是更有趣的是 ...

  3. Jasper_table_Cloud not resolve style(s)

    resolve method : delete style="".

  4. Xcode-Xcode 7.3 解决不能自动联想问题-备

    一.问题: 升级Xcode 7.3 之后发现导入头文件之后,没法自动联想. 二. 解决办法: 打开Xcode --> Target --> BuildSettings --> App ...

  5. angular2 学习笔记 ( ngModule 模块 )

    2016-08-25, 当前版本是 RC 5. 参考 : https://angular.cn/docs/ts/latest/guide/ngmodule.html 提醒 : 这系列笔记的 " ...

  6. 关于C51的中断函数要注意的几个问题

    转载自:http://blog.21ic.com/user1/531/archives/2006/16909.html 最近在虾潭逛,发现一些小虾米对C51中断函数有些不了解,今天周末,抽空发个技术帖 ...

  7. Another Look at Events(再谈Events)

    转载:http://www.qtcn.org/bbs/simple/?t31383.html Another Look at Events(再谈Events) 最近在学习Qt事件处理的时候发现一篇很不 ...

  8. hibernate 映射<三>一对一外键键关联

    bean 关系: 正向工程: 反向工程: 逆向生成步骤: 生成的xml: ... from hbm_one2one_pk.person person0_ left outer join hbm_one ...

  9. 【转】java byte转long、double、float、int、short,或者long、double、float、int、short转byte

    原文网址:http://www.xuebuyuan.com/988752.html java byte与其他数据类型的转换主要用于二进制数据的编码和解码,主要用于网络传输,读写二进制文件,java和c ...

  10. Android客户端实现七牛云存储文件上传

    1.简单文件上传  上传模型如下. 1.1获得Token 不管是简单文件上传,还是分片上传.断点续传 都需要首先访问服务器,以获得上传凭证信息Token..用于测试时,可以用本地模拟Token信息(有 ...