Search code examples
windowsdlsdl-2

Does SDL2 provide platform-agnostic means to keep a window from closing?


I understand that SDL2 raises SDL_QUIT and SDL_WINDOWEVENT_CLOSE events (and use the former to break the app's render loop), but I don't understand how handling either event provides the ability to prevent the underlying window from closing (e.g. for user confirmation of exit).

Do I need to handle this per-platform?


Solution

  • To prevent the window from closing and application from terminating, you simply do nothing on receiving SDL_QUIT and SDL_WINDOWEVENT_CLOSE.