are you on Windows?
- write an event filter function following this signature: SDL2/SDL_EventFilter - SDL2 Wiki
- you must return 1 from this event filter. if you return zero, you break SDL.
- for
SDL_WINDOWEVENT_SIZE_CHANGED
andSDL_WINDOWEVENT_RESIZED
, execute code strictly related to resizing, NOT rendering - catch
SDL_WINDOWEVENT_EXPOSED
, then execute render-related code - these three events are guaranteed to be watched/filtered in main thread, despite documentation saying they can be called from any thread. you can write assertions to ensure this, if you feel paranoid
- during initialization, activate the callback with an event watcher: SDL2/SDL_AddEventWatch - SDL2 Wiki
see this: Is it thread-safe to render inside event watcher?
and this: Live-resize of an SDL window