windows 是否可以在上下文/线程之间共享 opengl 帧缓冲区对象?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4385655/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to share an opengl framebuffer object between contexts/threads?
提问by Plow
I want to render my scene in one thread and then blit the result in window owned by another thread. To avoid reading the framebuffer back to cpu memory, I would like to use a framebuffer object. So far I have not been able to get this to work (white texture), which makes me believe that this is not supported by opengl.
我想在一个线程中渲染我的场景,然后在另一个线程拥有的窗口中 blit 结果。为了避免将帧缓冲区读回 CPU 内存,我想使用帧缓冲区对象。到目前为止,我还没有能够让它工作(白色纹理),这让我相信这不受 opengl 支持。
- Is it possible to share framebuffer objects between different contexts?
- Is it possible to share a framebuffer object between different threads, given that the object is only bound by one thread at a time?
- 是否可以在不同上下文之间共享帧缓冲区对象?
- 鉴于对象一次仅受一个线程绑定,是否可以在不同线程之间共享帧缓冲区对象?
If someone can point me to where this is described in the documentation, that would be a bonus.
如果有人可以指出我在文档中描述的位置,那将是一个奖励。
采纳答案by ltjax
It is not possible to share framebuffers between different contexts. See the first paragraph of Appendix D, OpenGL 3.3 spec. However, you can share textures and renderbuffers, which should give you want you need.
在不同的上下文之间共享帧缓冲区是不可能的。请参阅附录 D,OpenGL 3.3 规范的第一段。但是,您可以共享纹理和渲染缓冲区,这应该可以满足您的需求。
As for the threading: It should be possible, but it is generally advised not to issue GL commands from multiple threads (Because it is just very hard to synchronize). Usually, you would copy the contents to a pixel-buffer-object and and map it from the GL thread, then use the mapped pointer from the other thread.
至于线程:应该可以,但一般建议不要从多个线程发出GL命令(因为它很难同步)。通常,您会将内容复制到像素缓冲区对象并从 GL 线程映射它,然后使用来自另一个线程的映射指针。