OpenGL and multithreading

From OpenGL Wiki
Revision as of 22:23, 6 April 2009 by V-man (talk | contribs) (New page: === Can I create an OpenGL context for a control in a different thread than the one in which the was created on? === Yes. According to the Microsoft documents (MSDN), there is no restricti...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Can I create an OpenGL context for a control in a different thread than the one in which the was created on?

Yes. According to the Microsoft documents (MSDN), there is no restriction. You can probably do the same on *nix systems as well.

Can I create and dispose of resources in a different thread than the one the OpenGL context is in?

If you make the context current (wglMakeCurrent for Windows). However, it does not buy you much, if anything at all, so it's not worth the trouble.
It is recommended that you call wglMakeCurrent(NULL, NULL) if GL context is current on another thread, then call wglMakeCurrent(dc, glrc) in the other thread.

Can I make GL calls?

Yes, see above to see how to call wglMakeCurrent. Again, it doesn't improve performance. GL function calls go to the driver and the driver collects the function calls into command lists, which finally get sent to the GPU. Usually there is just 1 GPU so there is no performance increase.