heyx3 / Bplus.jl

A modern OpenGL 4.6 rendering framework, written in Julia.
Other
70 stars 3 forks source link

Fix the `GL.Context` callback for GLFW 'joystick connected' events #23

Open heyx3 opened 1 year ago

heyx3 commented 1 year ago

For some reason, GLFW's callback for a joystick connecting or disconnecting is not associated with a specific Window. This means it's not tied to a particular GL.Context either.

The problem is, we'd really like it to act no differently than the other callbacks, exposed through GL.Context.

So, we need a true (not thread-local) singleton which hooks into GLFW the first time it's initialized (or how about on __init__).

The hard part is how to provide the callback on each context's task. It will involve multithreading work. I think the most feasible option is to enqueue the events into each context using a read/write lock, then have the context check the queue whenever it gets a chance, such as during GL.set_render_state_field!().