Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The documentation is maybe worded in a slightly misleading way. A better wording would be: </p> <blockquote> <p>It is strongly recommended that all OpenGL and GLFW calls (except for thread management and synchronization calls) are made <strong>from a single thread, preferrably the same one that called <code>glfwInit</code> and <code>glfwOpenWindow</code></strong>, which should not be a big problem since only a single window is supported. This method is also compatible with the future direction of GLFW.</p> </blockquote> <p>The reason for that is that OpenGL has the concept of a "current thread" for its contexts, which is the one thread that may legitimate modify or use that context at a given time. A context initially belongs to the thread that created it. You can make it "current" in some other thread by calling <code>wglMakeCurrent</code> or <code>glxMakeCurrent</code>, which unlike GLFW is not portable (but GLFW might have a wrapper for that, I'm not sure).</p> <p>It is of course very well possible to have several independent contexts, and it is possible to access the same context from several threads by making the same context current in each thread prior to using it. And lastly, it is possible to have several contexts in several threads that share state.<br> However, none of these options is the regular case, as it either involves non-neglegible synchronization overhead or is not suitable for the common usage of OpenGL. Any other thing than "one thread, one context" usually, with very few exceptions, doesn't offer any advantage, but comes with needless complexity.</p> <p>The <em>regular case</em> is therefore to have exactly one context that is used by exactly one thread, and optionally some worker threeads that help with shuffling data into mapped buffers.</p> <p>As for "main thread" versus "any thread", there is no difference. The main thread is just <em>incidentially</em> the one that initializes GLFW (and thus OpenGL), most of the time.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload