With vsync enabled, glfwSwapBuffers blocks. To work around it, I created another thread for logic, while the main one did drawing only. Basically, main thread loop did this:
- Lock mutex.
- Draw.
- Unlock mutex.
- Call glfwSwapBuffers.
The secondary thread loop was doing the following at much faster rate (100 times per second):
- Lock mutex.
- Do logic. This involves a call to glfwPollEvents and other non-rendering glfw functions.
- Unlock mutex.
The problem is that I looked at the documentation and it says that glfwPollEvents could only be used from the main thread, so I should move it to the the main thread (which is drawing and is tied to screen refresh rate). So this essentially ties my logic code (which runs at arbitrary rate) with drawing code (which is tied to screen refresh rate because glfwSwapBuffers blocks with vsync enabled).
Any way to work around this?