call OpenGL functions from another thread
My application has two threads: A and B. The A is the main thread and B is my video thread. The video thread has an initialized OpenGL context where开发者_StackOverflow OpenGL functions work properly. However, when I call OpenGL functions from thread A, the function failed with a 1282 error (GL_INVALID_OPERATION) Is it possible to call OpenGL functions from my main thread (A) ?
Unless you are doing actual background rendering of slow content, this is probably not going to give you a performance delta.
On Windows, open gl contexts are per thread. Ensure that you call wglMakeCurrent from your worker thread before attempting to call open gl functions.
Open GL is not thread safe. If you attempt to make the same context current on multiple threads, it won't stop you. It will just explode.
GL is not Thread Safe, and therefore you can not call GL functions from 2 different threads. You will have to protect each gl part with mutexes, which kills any performance boost you would have expect plus overhead of mutex locking and probably required context switching.
精彩评论