From: Nigel S. a. F. S. <ni...@ni...> - 2003-12-29 21:44:36
|
> Just in case it is lost in your mailbox: > http://msdn.microsoft.com/library/en-us/dllproc/base/msgwaitformultipleobjects.asp This works for me on Win32, havn't tested the Unix/X11 path... static void fgSleepForEvents( void ) { long msec; if (fgState.IdleCallback || fgHavePendingRedisplays()) return; msec = fgNextTimer(); if (fgHaveJoystick()) msec = MIN(msec,10); /* Assume joystick polling 0.01sec interval */ msec = MIN(msec,100); /* Limit sleep to 0.1sec */ #if TARGET_HOST_UNIX_X11 { fd_set fdset; int err; int socket; struct timeval wait; socket = ConnectionNumber( fgDisplay.Display ); FD_ZERO( &fdset ); FD_SET( socket, &fdset ); wait.tv_sec = msec / 1000; wait.tv_usec = (msec % 1000) * 1000; err = select( socket+1, &fdset, NULL, NULL, &wait ); if( -1 == err ) fgWarning("freeglut select() error: %d\n", errno); } #elif TARGET_HOST_WIN32 MsgWaitForMultipleObjects(0,NULL,FALSE,msec,QS_ALLEVENTS); #endif } |