1 2 3 4 5 6 7 8
| Starting with release 1.2.0, thread-safe support for multiple rendering contexts, possibly with different capabilities, is available. Since this is not required by most users, it is not added to the binary releases to maintain compatibility between different versions. To include multi-context support, you have to do the following:
1. Compile and use GLEW with the GLEW_MX preprocessor token defined.
2. For each rendering context, create a GLEWContext object that will be available as long as the rendering context exists.
3. Define a macro or function called glewGetContext() that returns a pointer to the GLEWContext object associated with the rendering context from which OpenGL/WGL/GLX calls are issued. This dispatch mechanism is primitive, but generic.
4. Make sure that you call glewInit() after creating the GLEWContext object in each rendering context. Note, that the GLEWContext pointer returned by glewGetContext() has to reside in global or thread-local memory.
Note that according to the MSDN WGL documentation, you have to initialize the entry points for every rendering context that use pixel formats with different capabilities For example, the pixel formats provided by the generic software OpenGL implementation by Microsoft vs. the hardware accelerated pixel formats have different capabilities. GLEW by default ignores this requirement, and does not define per-context entry points (you can however do this using the steps described above). Assuming a global namespace for the entry points works in most situations, because typically all hardware accelerated pixel formats provide the same entry points and capabilities. This means that unless you use the multi-context version of GLEW, you need to call glewInit() only once in your program, or more precisely, once per process. |
Partager