// 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. codevs 1061 重复子串

    题目描述 Description 某电视台在每一个星期天都有一个福利彩票节目,在该节目中有一个考察幸运观众记忆力的节目.节目的安排是这样的:首先由节目主持人说出一串诸如“左1右2左2左3右4左1”的数 ...

  2. 使用dom4j生成xml字符串,以及解析xml字符串

    基于dom4j-1.6.1.jar import java.io.IOException; import java.io.StringWriter; import java.util.ArrayLis ...

  3. 导出excel的三种方式

    第一种是Response输出,这种方式输出的文件不符合标准的excel格式,在打开的时候会有提示,而且不好控制内容.第一种是Response输出,这种方式输出的文件不符合标准的excel格式,在打开的 ...

  4. ChangeServiceConfig2 function

    ChangeServiceConfig2 function   Changes the optional configuration parameters of a service. Syntax C ...

  5. poj2063 Investment(多次完全背包)

    http://poj.org/problem?id=2063 多次完全背包~ #include <stdio.h> #include <string.h> #define MA ...

  6. cf581C Developing Skills

    Petya loves computer games. Finally a game that he's been waiting for so long came out! The main cha ...

  7. JS~模拟表单在新窗口打开,避免广告拦截

    说起广告拦截,这应该是浏览器的一个特性,它会将window.open产生的窗口默认为一个广告,将它进行拦截,但有时,这不是我们所希望的,有时,我们就是需要它在客户端的浏览器上弹出一个新窗口,以展示数据 ...

  8. String path = request.getContextPath();这段什么用

    <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+ ...

  9. C#使用jmail组件发送邮件

    1.安装 命令行环境下,到jmail.dll所在目录,运行regsvr32 jmail.dll 2.代码 #region 发送邮件    /// <summary>    /// 发送邮件 ...

  10. Java 之 StringTokenizer

    class StringTokenizer Object to: break a string into tokens. Contructs StringTokenizer(String str)   ...