OpenGL:快速离屏渲染
我需要使用 OpenGL 在屏幕外渲染大量(数万)图像。
我在Windows下运行并使用QT作为框架。 解决方案只能是Windows,这并不重要。
根据我使用谷歌的发现,有很多选择可以做到这一点 这篇文章看起来相当过时,提出了几种方法,其中相关的方法是:
- Windows 特定的 - 使用 CreateDIBSection 并以某种方式将纹理绑定到它。
- 使用我的卡似乎支持的 pbuffers 扩展。
此线程(消息 6)建议了一种 QT 特定方式使用 QGLWidget::renderPixmap 执行此操作
我的问题是 - 哪一种是最快的方法? pbuffers 似乎是最安全的选择,因为它保证在硬件上执行,但使用 CreateDIB 方法是否也会通过硬件? 那么QT方法呢? 这似乎存在一些上下文创建问题。 我当然不想为我创建的每个图像创建一个新的上下文。
有人对此有一些好的经验吗?
编辑:回答评论 -
我有一个完全不变的恒定场景,并且我从许多不同的角度渲染它。 现在图像会返回给用户并由 CPU 进行处理。 未来它们可能会在 GPU 上进行处理。
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.
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 specific - Use
CreateDIBSection
and somehow bind the texture to it. - Use the pbuffers extension which I seem to be supported on my card.
This thread (Message 6) suggests a QT specific way of doing this using QGLWidget::renderPixmap
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?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 FBO。 它快速、便携并且比 pbuffers 更好用。
编辑:为了获得最佳性能,请在两个不同的 FBO 之间交替渲染:
这样,您可以读回一个 FBO,然后在GPU 并行渲染到另一个 GPU。
Use FBO. It's fast, portable and much nicer to use than pbuffers.
EDIT: For best performance, alternate rendering between two different FBOs:
This way you can be reading back one FBO and then processing it while the GPU renders to the other one in parallel.