OpenGL: Fast off-screen rendering

假装没事ソ 提交于 2019-12-05 01:30:50

问题


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.


回答1:


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

EDIT: For best performance, alternate rendering between two different FBOs:

  1. Render to A
  2. Render to B
  3. Read back from A and process it
  4. Render to A
  5. Read back from B
  6. Goto 2

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



来源:https://stackoverflow.com/questions/214437/opengl-fast-off-screen-rendering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!