// 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. Nginx源码研究三:Epoll在NGINX中的使用

    Web服务器在面对高并发的情况下,网络的IO一般选择IO复用,像apache选择的Select/poll.Nginx在linux 2.6后选择Epoll做网路IO,提高了WEB服务的并发能力. 在本章 ...

  2. sersync做实时同步(第一步)

    两台主机,一台主服务器(192.168.0.109).一台目标服务器(192.168.0.212) 1.配置目标服务器(192.168.0.212);就是配置rsync服务器.在配置文件/etc/rs ...

  3. Python自动化运维之7、生成器、迭代器、列表解析、迭代器表达式

    迭代器和生成器 1.迭代器 迭代器是访问集合元素的一种方式.迭代器对象从集合的第一个元素开始访问,直到所有的元素被访问完结束.迭代器只能往前不会后退,不过这也没什么,因为人们很少在迭代途中往后退.另外 ...

  4. iOS-OC命名规范

    IOS开发(OC)中的命名规范 正文:通过读写大量代码我有自己的一套编程思路和习惯,自认为自己的编码习惯还是不错的,代码结构也算清晰,因为我一直以来都是代码看的多写的多,但是总结的比较少,知识经常不成 ...

  5. (摘)SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

    Linux下安装好Oracle 10g后运行sqlplus出现故障如下:[oracle@localhost oracle]$ ./sqlplusError 6 initializing SQL*Plu ...

  6. ural 1874 Football Goal

    #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> u ...

  7. PowerShell控制台输出符号+函数参数类型指定+文本内容读取

    There are several ways: Write-Host: Write directly to the console, not included in function/cmdlet o ...

  8. 抛出异常的区别 throw 和throw ex

    在面试的过程中提到了异常捕获的的几种用法,之前一直使用但是没有仔细留意,调试程序的过程中发现还是有区别的,主要区别在堆栈信息的起始点不同,下边我们通过实例来看这集中不同的抛出异常的方法. 一般我们推荐 ...

  9. Android 调用图库选择图片实现和参数详解

    //选择图片,调用图库        bt4.setOnClickListener(new OnClickListener() { @Override            public void o ...

  10. ubuntu配置bridge网桥

    先安装uml-utilities,该工具包含建立虚拟网络设备(所谓的“TAP interfaces”)的工具: sudo apt-get install uml-utilities 安装 桥接工具 b ...