osgMulitiplerendertargets sample 中fbo使用【HTC VIVE开发中应用】
osgmultiplerendertargets.cpp
......................................
// now create the camera to do the multiple render to texture
{
osg::Camera* camera = new osg::Camera;
// set up the background color and clear mask.
camera->setClearColor(osg::Vec4(0.1f,0.1f,0.3f,1.0f));
camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// the camera is going to look at our input quad
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1,0,1));
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());
// set viewport
camera->setViewport(0, 0, tex_width, tex_height);
// set the camera to render before the main camera.
camera->setRenderOrder(osg::Camera::PRE_RENDER);
// tell the camera to use OpenGL frame buffer objects
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
// attach the textures to use
for (int i=0; i<NUM_TEXTURES; i++) {
if (useMultiSample)// 使用多重渲染方式消除锯齿现象
camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER0+i), textureRect[i], 0, 0, false, 4, 4);
else
camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER0+i), textureRect[i]);
}
// we can also read back any of the targets as an image, modify this image and push it back
// 绑定一张image获取fbo渲染结果
if (useImage) {
// which texture to get the image from
const int tex_to_get = 0;
osg::Image* image = new osg::Image;
if (useHDR) {
image->allocateImage(tex_width, tex_height, 1, GL_RGBA, GL_FLOAT);
} else {
image->allocateImage(tex_width, tex_height, 1, GL_RGBA, GL_UNSIGNED_BYTE);
}
// attach the image so its copied on each frame.
camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER0 + tex_to_get), image);
camera->setPostDrawCallback(new MyCameraPostDrawCallback(image));
// push back the image to the texture
textureRect[tex_to_get]->setImage(0, image);
}
// add the subgraph to render
camera->addChild(cam_subgraph);
parent->addChild(camera);
}
osgMulitiplerendertargets sample 中fbo使用【HTC VIVE开发中应用】的更多相关文章
- 怎样实现了捕获应用中的日志在android开发中
怎样实现了捕获应用中的日志在android开发中,大家可研究一下. Process mLogcatProc = null; BufferedReader reader = null; try { mL ...
- HTC VIVE SDK 中的例子 hellovr_opengl 程序流程分析
最近Vive的VR头盔设备很火,恰逢项目需求,所以对 SDK 中的例子 hellovr_opengl 做了比较细致的代码分析,先将流程图绘制如下,便于大家理解. 在ViVe头盔中实现立体效果的技术核心 ...
- HTC Vive开发笔记之UI Guideline
本文转自HTC官方论坛,原址https://www.htcvive.com/cn/forum/chat.php?mod=viewthread&tid=1641&extra=page=1 ...
- HTC Vive开发笔记之手柄控制
怎么安装设备,配置环境我就不说了,自行百度,教程很多也很简单.接下来说下Vive手柄的控制. 手柄是HTC Vive的重要交互手段,我们通过第一个图片应该对其有一个直观的了解了,总共是九个按钮: 第一 ...
- HTC Vive开发笔记之SteamVR插件集成
重要组件 SteamVR_Camera VR摄像机,主要功能是将Unity摄像机的画面进行变化,形成Vive中的成像画面 使用方法: l 在任一个摄像机上增加脚本 l 点击Expand按钮 完成以上操 ...
- unity3D HTC VIVE开发-物体高亮功能实现
在VR开发时,有时需要用到物体高亮的功能.这里使用Highlighting System v3.0.1.unitypackage插件实现. Highlighting System v3.0.1的介绍访 ...
- HTC vive开发:关于手柄按键
一.关于左右手柄的对应关系 两个手柄和SteamVR_TrackedObject.EIndex是对应的,一个是EIndex.Device2,另一个是EIndex.Device3(有编号的那个) 在场景 ...
- HTC Vive开发笔记之手柄震动
手柄震动的代码SteamVR_Controller脚本的最上面的注释里面就有说明,其实也很简单 // Example usage: //这个栗子是左手柄震动 右手震动只需把Leftmost换成Righ ...
- 用Unity开发HTC VIVE——手柄控制篇
写这篇文章的原因主要是因为现在虚拟现实非常的火爆但目前主流的虚拟现实设备(HTC VIVE)的教程却少的可怜,这个我深有体会.所以,我想将我平时开发中遇到的问题以及解决方法记录下来,分享给大家,若其中 ...
随机推荐
- 破解wifi时遇到rtl8187 - [phy1]SIOCSIFFLAGS: Name not unique on network
当我使用我的ubuntu利用aircrack-ng套件进行wifi破解时 遇到如下问题 rtl8187 - [phy1]SIOCSIFFLAGS: Name not unique on network ...
- linux下使用wget下载整个网站
linux下可以用wget下载整个网站,而且网站链接中包含utf-8编码的中文也能正确处理. 简要方法记录如下: wget --restrict-file-name=ascii -m -c -nv - ...
- python3 进程_multiprocessing模块
'''多进程优点:可以利用多核,实现并行运算缺点:1.开销太大: 2.通信困难使用方式跟开多线程一样''' 多进程 import multiprocessing import time,os def ...
- XCode Playground Overview
http://rshankar.com/xcode-6-and-playground/ Playground is an interactive work environment that allow ...
- javascript 实现购物车页面
跟商城有关系的网站,难免会有购物车的结账界面. 我用javascript实现了增加数量/减少数量,实时计算总金额,删除该商品,选中商品/反选商品/全选/全反选...的操作. 欢迎指点!~ 效果如图:( ...
- git常用命令收集
[git远程操作命令] 1.$ git remote –v #查看本地配置的所有远程仓库,内容为远程仓库的地址和本地别名 harvey@harvey:~/node$ git remote -v nod ...
- could not find or load the Qt platform plugin "xcb"
没有解决 一些资料: https://wiki.qt.io/Install_Qt_5_on_Ubuntu http://doc.qt.io/qt-5/linux-requirements.html h ...
- Linux下查看nginx、mysql、php的安装路径和编译参数
一:查看安装路径: 1.nginx安装路径: ps -ef | grep nginx 摁回车,将出现如下图片: master process 后面的就是 nginx的目录. 2.mysql安装路径: ...
- 初始github——git的简单使用
初学者~ 有两篇吧,一篇在github上 https://github.com/DefaultYuan/Git-Pro/wiki/Introduction 文章来源:<git的简单使用> ...
- opencv对鼠标的响应
#include <cv.h> #include <highgui.h> #include <stdio.h> #pragma comment(lib,&quo ...