Advertisement

[SDL] Event queue question

Started by October 10, 2011 06:16 PM
1 comment, last by gapern 13 years, 1 month ago
Hi. I'm just wondering if the event queue ever needs to be cleared and if so how do I do it? I'm seeing the SDL_FlushEvent function and I'm assuming that's how clearing the queue would be done but I'm not sure if I need too or not. Consider this example code.


while(key.a != pressed)
{
dostuff();
}

while(key.b != pressed)
{
domorestuff();
}
endprogram();



The first loop runs until I hit a. While in the first loop I hit the b key. Assume b is not used in the first loop so it's just stored in the event queue. Now I hit a and break out of the first loop. The program immediately finds b and ends the program but I didn't want the program to end yet.

Is the problem I just pointed out valid?
If you use SDL_PollEvent or SDL_WaitEvent the events are removed from the event queue and there is no need to clear the queue yourself.
Advertisement
The entire queue is cleared after I poll once? So I can only process one event per frame?

This topic is closed to new replies.

Advertisement