All you need to set this up is to create an OpenGL context for each thread, who has its context shared with your main thread's context. The process for doing this is surprisingly easy, it can just be one function call. Here's an example
1 2 | HGLRC MainContext = wglCreateContextAttribsARB(WindowDC, 0, OpenGLAttribs); HGLRC WorkerThreadContext = wglCreateContextAttribsARB(WindowDC, MainContext, OpenGLAttribs); |
After creating the context, all you have to do is call wglMakeCurrent(WindowDC, WorkerThreadContext) from within your thread. You only have to call this once within the thread's life cycle.
Buyer beware, I wouldn't recommend multithreading OpenGL on a large-scale. Just keep it to simple things like this. This is also throwing a GL_INVALID_OPERATION for me 1/50 times so maybe its not shippable?