Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 907
Plow Avatar asked Dec 08 '10 08:12

Plow


People also ask

What is the different between Renderbuffer and framebuffer?

Creating a renderbuffer object is similar to texture objects, the difference being that this object is specifically designed to be used as a framebuffer attachment, instead of a general purpose data buffer like a texture.

What is OpenGL context?

An OpenGL rendering context is a port through which all OpenGL commands pass. Every thread that makes OpenGL calls must have a current rendering context. Rendering contexts link OpenGL to the Windows windowing systems. An application specifies a Windows device context when it creates a rendering context.

What is a framebuffer attachment?

Framebuffers represent a collection of memory attachments that are used by a render pass instance. Examples of these memory attachments include the color image buffers and depth buffer that we created in previous samples. A framebuffer provides the attachments that a render pass needs while rendering.

What is frame buffer in OpenGL?

A Framebuffer is a collection of buffers that can be used as the destination for rendering. OpenGL has two kinds of framebuffers: the Default Framebuffer, which is provided by the OpenGL Context; and user-created framebuffers called Framebuffer Objects (FBOs).


1 Answers

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.

like image 95
ltjax Avatar answered Nov 08 '22 21:11

ltjax