开发者

Is it possible to share an opengl framebuffer object between contexts/threads?

开发者 https://www.devze.com 2023-01-29 04:47 出处:网络
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 fa

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.

  1. Is it possible to share framebuffer objects between different contexts?
  2. Is it possible to share a framebuffer object between different threads, given that the objec开发者_如何转开发t 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.


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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号