Hello everyone!
I have read the github discussion about the main thread being blocked while moving or resizing the window on some platforms. If I understand correctly this will not be an issue in SDL3 if you use the main callbacks.
My question is about the proposed workaround when using the traditional approach where SDL_PollEvent
is called manually (which is the only option in SDL2).
slouken wrote:
I’ve added a solution that dovetails nicely with the new main callbacks in SDL 3.0 and if you’re not using that you can set an event watcher to handle expose events and draw then.
There is also an example that uses this approach. It uses SDL_AddEventWatch
to register a callback that ends up calling a bunch of render functions (including SDL_RenderPresent
).
The wiki page for SDL_RenderPresent says:
“You may only call this function on the main thread.”
The wiki page for SDL_AddEventWatch says:
“WARNING: Be very careful of what you do in the event filter function, as it may run in a different thread!”
Am I missing something, is there perhaps an undocumented guarantee that the event watcher will always be invoked on the main thread when dealing with window events, or is this simply not thread-safe?