windowsmultithreadingopenglframebufferopenglcontext

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


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 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.


Solution

  • 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.