// 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. PHP防止SQL注入的方法

    [一.在服务器端配置] 安全,PHP代码编写是一方面,PHP的配置更是非常关键. 我们php手手工安装的,php的默认配置文件在 /usr/local/apache2/conf/php.ini,我们最 ...

  2. MFC基本框架

    MFC基本框架 By  小戴 发表于 2006-12-21 15:59:00  MFC 应用程序框架 1. MFC 简介: MFC ( Microsoft Foundation Class )是由 ...

  3. 【HDOJ】4504 威威猫系列故事——篮球梦

    水题. #include <cstdio> #include <cstdlib> #include <cstring> #define MAXN 25 ]; voi ...

  4. 【转】JAVA 读写二进制文件

    原文网址:http://shiminghua234.blog.163.com/blog/static/263912422011619102350866 import java.io.*; /** * ...

  5. HDOJ 1390 Binary Numbers(进制问题)

    Problem Description Given a positive integer n, find the positions of all 1's in its binary represen ...

  6. HDU_2055——刷题不要使用fflush()

    Problem Description we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, ... f(Z) = 26, f(z) = -26; G ...

  7. HDU_2044——蜜蜂走蜂房,递推

    Problem Description 有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行.请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数. 其中,蜂房的结构如下所示.   Input 输入数据的 ...

  8. 日积月累:EditText软键盘的显示和隐藏

    在工作过程中,常常会遇见需要根据自己的需求,控制文本框的键盘显示和隐藏. 通过查阅Android文档,介绍可以通过在清单文件中<activity>元素中添加android:windowSo ...

  9. Spring 基于注解零配置开发

    本文是转载文章,感觉比较好,如有侵权,请联系本人,我将及时删除. 原文网址:< Spring 基于注解零配置开发 > 一:搜索Bean 再也不用在XML文件里写什么配置信息了. Sprin ...

  10. Struts 2零配置

    从struts2.1开始,struts2不再推荐使用Codebehind作为零配置插件,而是改为使用Convention插件来支持零配置,和Codebehind相比,Convention插件更彻底,该 ...