maybe I’ve just mised something in docs, but I can’t figure out, how to dispatch an event for application from different program thread.
My pseudocode:
void main() {
SDL_init();
createThread(&secondThread);
while(!quit) {
/*EVENT HANDLER*/
SDL_Event event;
SDL_WaitEvent(&event);
switch(event.type) {
/*manage events*/
}
}
SDL_Quit();
}
void secondThread() {
char output[255];
readSocket(output); //Blocking function
if(output=="EXIT")
SDL_dispatchEvent(SDL_QUIT);
return 0;
}
It sounds like you’re looking for
SDL_PushEvent().It is even documented as being thread-safe, which of course is not something one can generally assume for many libraries.