I agree that having something like select() would be more useful.
Me too, but that’s one of the trickiest part, because the equivalent
APIs are rather different from one platform to the other.
Here’s a PyGame snippet that does this (only on x11):
Of note that this is more or less what my demo program at the top of
this thread does, but that there is some problem with it and switching
to fullscreen, where SDL seems to rely on SDL_PollEvent() to be called
when there is nothing to do, at certain (more or less random) times. I
find this particular bit of code rather strange, my Xlib code that
does switching to/from fullscreen didn’t need any of this and seems to
work fine?
Maybe some esoteric bit of knowledge about mysterious behaviour of
some X11 servers that I don’t know? Somebody knows?
Also, I think removing SDL_PushEvent() would solve a lot of
problems… including simplifying event blocking when it is
implemented. It doesn’t make sense to use an outside library to manage
a game’s event queue to me…
I think it’s mostly used for communicating to the main thread from
other threads. I’m not that offended by the concept, but in my own
programs, I tend to reuse timers in that case, simply adding a timer
for now. I use a pipe set in non-blocking mode to wake up the
select() from other threads when signals come in (there’s a classic
race conditional regarding select() and signal handling, again
XtAppAddSignal deals with that) or when timers are added (so that we
"notice" them if they’re from another thread). Just write one byte,
ignore any error, and remember to read all the bytes from the pipe
after returning from select()! See
http://pphaneuf.livejournal.com/158971.html, and maybe
http://pphaneuf.livejournal.com/158346.html too (although SDL’s need
in this matter are probably much simpler).On Thu, May 15, 2008 at 7:59 PM, Forrest Voight wrote: