Re: SDL Event Help
- Posted by ChrisB (moderator) Oct 22, 2022
- 724 views
Hi
Me applying my dull brain
event is defined as an object, a sequence.
event is sent off to be filled by SDL_PollEvent, from the wiki
event : the SDL_Event structure to be filled with the next event from the queue, or NULL
this returns 1 or 0 for presence or not of an event, if there is an event, then event is the address of the event structure
again from the wiki SDL_Event A union that contains structures for the different event types.
This is where my brain starts to get fried
SDL_pollevent returns the pointer to the SDL_Event, and out of that you want to retrieve SDL_Event.type, and if that's SDL_QUIT then quit. Luckily it looks like it's the first element of the union, so just retrieve that! Simple (?!)
or, in C
SDL_Event e; for (;;) { SDL_PollEvent(&e); --send address of structure, fill structure if (e.type == SDL_QUIT) { SDL_Log("Program quit after %i ticks", e.quit.timestamp); break; } }
Cheers
ChrisProbablyNoHelpAtAllButCuriousAnyway