OpenGL multiple Context and thread

Hi all,

I have a small issue and need help. Thanks for reading.
The idea is to make a thread to render several stuff, and then gather all the stuff in the same window.

as an example, lets say :
1 thread that render lost of circle to a texture
1 thread that render lost of triangle to texture

there is no link between the 2 render, i mean it could be 2 seperate applications.
and then gather the 2 texture , and use them as mapping on a cube …

The first thing i am thinking of is using FBO, but it looks like FBO share the same context as the original one.
And thate openGL stuff can be multithread if the context are different.

i was thinking of creating a thread with some FBO inside, but if information i gathered are right , it will not work.

i was also thinking of creating 2 application 1 client that render stuff and send them over UDP , to another one ( server ) that gather them, and use them … but there should be a simpler way …
Anyone have any clue ?

If you want to put them together into a cubemap then they’ll need to go into the same context and that needs to be in the same thread and, unless you do some work, that needs to be the main thread. There’s probably a workaround that will involve, as you suspected, an FBO and maybe sprites or VBOs depending on what your needs are. Why do need the two drawing routines threaded?

Well it is just a performance issue , i will probably have 10 totaly seperate FBO to draw, so better do it in thread than iteratively.
But i understood, opengl cannot be threaded because all thread will share the same context ?

the best way to figure out will be to try …


Well, you could thread the processing code and then do the drawing somewhere else or just use arrays of points with sprites if the objects you’re drawing are easy. Otherwise, well, have fun :slight_smile:

Even if you manage to thread the thing I don’t think you could get much more performance from it. You have only one graphics card and bus so no matter how much you try to parallelize things if the resources are unique the gain will probably be none.

thanks Joshua & Arturo !