Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which thread will call GLFW callbacks?

Tags:

glfw

I find these functions can register a callback for event from hardware(maybe? I'm not sure).

Like following functions.

glfwSetCursorPosCallback(window, mouse_callback);
glfwSetScrollCallback(window, scroll_callback);

I'm curious that how are these functions called. Does GLFW create a new thread by glfwInit to loop these functions? Or does GLFW register some listeners to listen these event from different hardware?

like image 368
ZeroZerg Avatar asked Sep 13 '25 04:09

ZeroZerg


1 Answers

The majority of the GLFW API is specified to only be used on the main thread (the thread that your application starts on). Every callback will be executed on this thread, within a call to glfwPollEvents or glfwWaitEvents. Your callbacks will never be executed on any other thread.

like image 136
Andreas detests censorship Avatar answered Sep 15 '25 03:09

Andreas detests censorship



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!