[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Xlib and file descriptors




> For a more complicated game, you can put a large number of fds in there
> to check for multiple sources of input. For example, if you decide your
> game has a timebase of 10 ms, you can have your event loop always go
> into a poll with the appropriate timeout and put all your fds in there
> (network sockets, pipes, input, files). Then you can use this as a
> cooperative scheduler, by making sure all your fds are set in
> non-blocking mode and that you never read or write too much data at a
> time. Then your loop will be able to know who's ready to write again,
> who's ready to read again, thus keeping the program very responsive.

Speaking of file descriptors, does anybody know of a way to get the fd
of the connection to the X server or at least a "pseudo-select" (like
Svgalib has)?

I'd like my game to be totally blocking on the poll/select call, with
everything expressed as file descriptors and with the timeout set for my
timebase (if poll returns after a timeout, I send a timetick event and
go back into the poll)...

-- 
Pierre Phaneuf
Ludus Design, http://ludusdesign.com/
"First they ignore you. Then they laugh at you.
Then they fight you. Then you win." -- Gandhi