[SDL] Re: Question about ignoring mouse events

Ryan C. Gordon icculus at icculus.org
Tue Nov 15 22:09:52 PST 2005


 > 	while (1) {
 > 		SDL_PollEvent(&event);
 > 	    	switch (event.type) {

You _need_ to check the return value from SDL_PollEvent!

What is happening is you are getting a legitimate mousebuttondown event, 
and then the next call to SDL_PollEvent() is reporting that there aren't 
any more events, but you are ignoring this and looking at the data from 
the previous event, which is still in the "event" object from the 
previous call.

It's best to do "while (SDL_PollEvent(&event))", handle all queued 
events, and then do whatever else you want the program to do, then 
repeat it again next frame.

--ryan.






More information about the SDL mailing list