I'm designing program that should demonstrate open CV on images. I've noticed very bad concept of basic SDL application - it consists of loop and delay.
while(true) {
while(event_is_in_buffer(event)) {
process_event(event);
}
do_some_other_stuff();
do_some_delay(100); //Program is stuck here, unable to respond to user input
}
This makes the program execute and render even if it is on background (or if re-rendering is not necessary in the first place). If I use longer delay, I get less consumed resources but I must wait longer before events, like mouse click, are processed.
What I want is to make program wait for events, like WinApi does or like socket requests do.
Is that possible?
Concept I want:
bool go=true;
while(get_event(event)&&go) { //Program gets stuck here if no events happen
switch(event.type){
case QUIT: go=false;
}
}