SDL2 & SDL_Event.
Posted: Sun Jun 20, 2021 5:44 am
Faced the need to use two event handlers.
Here's an example of a simple quick program (without any checks).
But, let's say, I want to have two threads that process clicks, AT THE SAME TIME, that is, synchronously, that is (I can't find the word), so that BOTH threads work, and if I have an ESC output on the second thread, then in the first stream, the output by the cross should be triggered. Usually, one of the streams replaces the other and it turns out that either the cross is triggered or the button (depending on which part of the file is inserted this or that block of code).
I feel that I need to dig in the direction of thread, although I'm not completely sure. Any ideas?
Here's an example of a simple quick program (without any checks).
Code: Select all
#include <SDL2/SDL.h>
int main(int argc, char **argv)
{
SDL_Window *window = SDL_CreateWindow("Hello World!", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0);
SDL_Event event;
while(1)
{
while(SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
atexit(SDL_Quit);
return 0;
}
}
}
return 0;
}I feel that I need to dig in the direction of thread, although I'm not completely sure. Any ideas?