OpenGL:快速离屏渲染 [英] OpenGL: Fast off-screen rendering

查看:48
本文介绍了OpenGL:快速离屏渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 OpenGL 在屏幕外渲染大量(数万个)图像.
我在 Windows 下运行并使用 QT 作为框架.解决方案只能是windows,没关系.

I need to render quite alot (tens of thousands) images off-screen using OpenGL.
I am running under Windows and using QT as a framework. the solution can be windows only, it doesn't really matter.

从我使用 Google 的发现来看,有很多选择可以做到这一点这篇文章 似乎过时了,提出了一些方法,其中相关的是:

From what I've found using Google there are a number of options for doing this This article which seems rather dated suggest a few ways, out of which the relevant ones are:

  • Windows 特定 - 使用 CreateDIBSection 并以某种方式将纹理绑定到它.
  • 使用我的卡上似乎支持的 pbuffers 扩展.
  • Windows specific - Use CreateDIBSection and somehow bind the texture to it.
  • Use the pbuffers extension which I seem to be supported on my card.

该线程(消息 6)建议使用 QGLWidget::renderPixmap

This thread (Message 6) suggests a QT specific way of doing this using QGLWidget::renderPixmap

我的问题是 - 哪种方式最快?pbuffers 似乎是最安全的选择,因为它保证在硬件上执行但不使用 CreateDIB 方法也通过硬件?QT方法呢?这个似乎存在一些上下文创建问题.我当然不想为我创建的每个图像创建一个新的上下文.
有没有人有这方面的好经验?

My question is - which one would be the fastest way? pbuffers seems to be the safest bet because it is guaranteed to be performed on the hardware but isn't using the CreateDIB method also goes through the hardware? What about the QT method? there seem to be some context-creation issue with this one. surely I would not want to create a new context for every image I create.
Does any one has some good experience with this?

编辑:回答评论 -
我有一个完全不变的场景,我从许多不同的角度渲染它.现在,图像返回给用户并由 CPU 处理.将来可能会在 GPU 上处理它们.

EDIT: Answering the comment -
I have a constant scene which doesn't change at all and I'm rendering it from many different viewpoints. For now the images go back to the user and will be processed by the CPU. Possibly in the future they are going to be processed on the GPU.

推荐答案

使用 FBO.与 pbuffers 相比,它快速、便携且好用得多.

Use FBO. It's fast, portable and much nicer to use than pbuffers.

为了获得最佳性能,在两个不同的 FBO 之间交替渲染:

For best performance, alternate rendering between two different FBOs:

  1. 渲染到 A
  2. 渲染到 B
  3. 从 A 回读并处理它
  4. 渲染到 A
  5. 从 B 回读
  6. 转到 2

通过这种方式,您可以读回一个 FBO,然后在 GPU 并行渲染到另一个 FBO 的同时对其进行处理.

This way you can be reading back one FBO and then processing it while the GPU renders to the other one in parallel.

这篇关于OpenGL:快速离屏渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆