31
System / Drawing from within a thread
« on: January 02, 2009, 01:15:50 pm »
I found and interesting note on multithreading in Microsoft's documentation to wglmakecurrent:
http://msdn.microsoft.com/en-us/library/ms537558(VS.85).aspx
There they say that one can/should use a separate device and rendering context per thread. I don't know much about OpenGL, but I wonder if is possible to display more than one context at a time.
By the way: Both the documentation of wglMakeCurrent and glXMakeCurrent state that the rendering context of the calling thread is changed, which implies that the function knows which thread it called.
When I posted my question here yesterday, I thought this might be a problem, but I simply didn't think of the possibility that a thread library will likely offer a function to retrieve the current thread's id. As the OpenGL calls are performed in the context of the calling thread, it shouldn't be a problem to find out which thread it called.
Oh, and I hope you didn't misunderstand my previous posting: A strict alternation of function calls alone didn't work, I had to make the window active/inactive each time in the appropriate thread. I slowly start to believe that it is really something thread-specific and not only parallelism-specific
http://msdn.microsoft.com/en-us/library/ms537558(VS.85).aspx
There they say that one can/should use a separate device and rendering context per thread. I don't know much about OpenGL, but I wonder if is possible to display more than one context at a time.
By the way: Both the documentation of wglMakeCurrent and glXMakeCurrent state that the rendering context of the calling thread is changed, which implies that the function knows which thread it called.
When I posted my question here yesterday, I thought this might be a problem, but I simply didn't think of the possibility that a thread library will likely offer a function to retrieve the current thread's id. As the OpenGL calls are performed in the context of the calling thread, it shouldn't be a problem to find out which thread it called.
Oh, and I hope you didn't misunderstand my previous posting: A strict alternation of function calls alone didn't work, I had to make the window active/inactive each time in the appropriate thread. I slowly start to believe that it is really something thread-specific and not only parallelism-specific