OpenGL and Multithreading

Hi everyone,

I have some questions !!!

Someone knows a good tutorial about the implementation of different threads within a openGL application. I want to separate sensing, the API and the rendering from my application.

Is it possible to separate the rendering (different windows) in threads?

Gracias!!

Hue

I’m not sure but I think to remember GL context(s) is(are) shared per-process.
As far as I know, there can be only 1 context per-process active at a given point in time. So, no, you cannot have 1 thread per window, each with its own render context (provided what I remember is correct) - unless each window is a different process obviously.
As for the rest, I don’t think it’s different from managing a standard shared resource.
Having input and rendering on different threads does not look so difficult.
I can tell the OpenGL superbible has a chapter on this but I don’t know if you can find resources on the net. Threading is usually seen as a black beast.

Obli, you’re far off.
In OpenGL a context can only be current in one thread at a time, and a thread can only have one current context. Given that multithreading is pretty simple.
Multiple windows of the same process can have multiple threads rendering to them each using its own context very easily.
You can even render to the same window with multiple threads, each holding its own context.
Such contexts can share data with wglShareLists as long as the windows use pixelformats from the same OpenGL implementation.
Cross-process OpenGL context access is illegal.

Originally posted by Relic:
Obli, you’re far off.
In OpenGL a context can only be current in one thread at a time, and a thread can only have one current context.

I went back to correct this and I see someone already pointed out. Thank you. I was pretty sure it was 1 active per process but if it is per thread then yes, I was wrong. Thank you.
My apologies to huesitos for having spread out this information which later turned out to be false, I really goofed up. Sorry, I wanted to put in what I remembered because I saw the message got no reply for “long time” in internet terms.
Now that I read this I realized what Relic said is right and my message is wrong.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.