You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-46Lines changed: 18 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -345,14 +345,12 @@ glbinding::Binding::initialize(false); // lazy function pointer resolution
345
345
346
346
*glbinding* has built-in support for multiple contexts. The only requirement is, that the currently active context has to be specified. This feature mixes well with multi-threaded applications, but keep in mind that concurrent use of one context often result in non-meaningful communication with the OpenGL driver.
347
347
348
-
To use multiple contexts, use your favorite context creation library (e.g., glut, SDL, egl, glfw, Qt) to request as much contexts as required. The functions to make a context current should be provided by this library and is not part of *glbinding* (except that you can get the current context handle). When using multiple contexts, first, each has to be initialized when active:
348
+
In order to use multiple contexts, use your favorite context creation library (e.g., glut, SDL, egl, glfw, Qt) to request the required contexts.
349
+
The functions to make a context current should be provided by these libraries and is not part of *glbinding* (except that you can get the current context handle).
350
+
When using multiple contexts, *glbinding* has to be initialized for each context (when current).
349
351
350
-
```cpp
351
-
// use context library to make current, e.g., glfwMakeCurrent(...)
352
-
glbinding::Binding::initialize();
353
-
```
354
-
355
-
Second, contexts switches are required to be communicated to *glinding* explicitly in order to have correctly dispatched function pointers:
352
+
Since each context can correspond to a different feature set of OpenGL and the drivers are free to assign their function pointers, *glbinding* cannot assume any equalities of requested function pointers.
353
+
Thus, contexts switches have to be communicated to *glbinding* explicitly in order to have correctly dispatched function pointers:
This feature is mainly intended for platforms where function pointers for different requested OpenGL features may vary.
366
-
367
-
**VS..**
368
-
369
-
##### Multiple OpenGL Contexts usage TODO
370
-
371
-
OpenGL allows for multiple contexts per program/process to be created and used. The one limitation is that only one context can be *current* at a given time. As each context can correspond to a different feature set of OpenGL and the drivers are free to assign their function pointers, glbinding **cannot** assume any equalities of requested function pointers. This means a user *must* tell glbinding of all contexts he wants to use and when the switches of *current* contexts occured.
372
-
Concluding, a user have to call the initialize method once per OpenGL context (when it is current) and has to update the current context if it has changed.
373
363
374
364
375
365
376
366
### Multi-Threading Support
377
367
378
368
Concurrent use of *glbinding* is mainly intended to the usage of multiple contexts in different threads (multiple threads operating on a single OpenGL context requires locking, which *glbinding* will not provide).
379
-
For this, *glbinding* supports multiple active contexts, one per thread. This necessitates that *glbinding* gets informed in each thread which context is currently active (see [multi-context](#multi-context-support)).
380
-
381
-
**VS TODO**
369
+
For it, *glbinding* supports multiple active contexts, one per thread.
370
+
This necessitates that *glbinding* gets informed in each thread which context is currently active (see [multi-context](#multi-context-support)).
371
+
Note: multi-threaded communication with OpenGL will most likely result in a meaningless sequence of OpenGL calls.
372
+
To avoid this, semantic groups of OpenGL calls should be treated as critical sections.
382
373
383
-
##### Multi-threaded OpenGL Context usage ToDO Remove?
374
+
##### Multiple OpenGL Contexts in Multiple Threads
384
375
385
-
If you want to use one OpenGL context in multiple threads, you have to call the initialize method once per thread. This is required because the *current* status of an OpenGL context is dependend on the current thread, i.e., you can have different contexts *current* in different threads. In order to allow for this, glbinding has to differentiate between registered OpenGL contexts per thread.
386
-
387
-
Beware of using one OpenGL context in multiple threads concurrently! Most likely, it won't result in a meaningful sequence of OpenGL calls. If you really want to use one OpenGL context in multiple threads, be sure to treat semantic groups of OpenGL calls as critical sections.
388
-
389
-
390
-
##### Multiple OpenGL Contexts in multiple Threads todo Remove?
391
-
392
-
The combination of multiple OpenGL contexts and multiple threads for OpenGL usage is supported by glbinding. You must tell glbinding which OpenGL context is used in which thread by calling the initialize method once the context is used first (```glbinding::Binding::initialize()```) and if you want to switch the *current* context for one thread, you have to update the current context, too (```glbinding::Binding::useCurrentContext()```). We strongly discourage the use of one context in multiple threads and we don't see real added value in using multiple contexts in one thread, so the main use case would be to use one OpenGL context per thread. This means you mainly have to register the context you want to use per thread once and leave it as is.
376
+
The combination of multiple OpenGL contexts and multiple threads for OpenGL usage is supported by *glbinding* in general.
377
+
You must tell *glbinding* which OpenGL context is used in which thread by calling the initialize method once the context is used first (```glbinding::Binding::initialize()```) and if you want to switch the current context for one thread, you have to update the current context, too (```glbinding::Binding::useCurrentContext()```).
378
+
However, we strongly discourage the use of one context in multiple threads.
393
379
394
380
395
381
@@ -414,15 +400,6 @@ The unresolved callback provides information about the (unresolved) wrapped Open
Note that these function signatures are *only* defined in the ```gl``` namespace.
465
+
Note that these function signatures are only defined in the ```gl``` namespace.
494
466
If you want to use per-feature API header and the patched signatures together in your project, you have to use either the ```gl``` namespace in addition to other ones or manually import the used alternative signatures into the other namespace using ```using``` declarations.
0 commit comments