Single Event Loop/Thread

For cross platform compatibility GLFW needs the event processing to be done on the main thread, see this comment and thread.

Since callbacks receive the window they are for, you can then dispatch the information as needed.

You do not need to create a new thread for every window, for example see tests/windows.c where four windows are created and then rendered to in turn. If you need to thread your rendering, keep the event loop and callbacks on the main thread and place the rendering on another thread - in OpenGL only one thread can have a given context current at any time.

Does this help sufficiently?

3 Likes