Splitting the platform-specific "fgSystemTime" code into its own functions

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1022 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
fayjf 2012-01-29 04:32:41 +00:00
parent 807a310099
commit 74bd5d3da6
2 changed files with 24 additions and 12 deletions

View File

@ -72,6 +72,7 @@ struct GXKeyList gxKeyList;
extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ); extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height );
extern void fgPlatformDisplayWindow ( SFG_Window *window ); extern void fgPlatformDisplayWindow ( SFG_Window *window );
extern unsigned long fgPlatformSystemTime ( void );
extern void fgPlatformSleepForEvents( long msec ); extern void fgPlatformSleepForEvents( long msec );
extern void fgPlatformProcessSingleEvent ( void ); extern void fgPlatformProcessSingleEvent ( void );
extern void fgPlatformMainLoopPreliminaryWork ( void ); extern void fgPlatformMainLoopPreliminaryWork ( void );
@ -174,6 +175,16 @@ void fgPlatformDisplayWindow ( SFG_Window *window )
{ {
fghRedrawWindow ( window ) ; fghRedrawWindow ( window ) ;
} }
unsigned long fgPlatformSystemTime ( void )
{
#if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY
struct timeval now;
gettimeofday( &now, NULL );
return now.tv_usec/1000 + now.tv_sec*1000;
#endif
}
#endif #endif
static void fghcbDisplayWindow( SFG_Window *window, static void fghcbDisplayWindow( SFG_Window *window,
@ -262,18 +273,9 @@ static void fghCheckTimers( void )
* when subtracting an initial start time, unless the total time exceeds * when subtracting an initial start time, unless the total time exceeds
* 32-bit, where the GLUT API return value is also overflowed. * 32-bit, where the GLUT API return value is also overflowed.
*/ */
unsigned long fgSystemTime(void) { unsigned long fgSystemTime(void)
#if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY {
struct timeval now; return fgPlatformSystemTime ();
gettimeofday( &now, NULL );
return now.tv_usec/1000 + now.tv_sec*1000;
#elif TARGET_HOST_MS_WINDOWS
# if defined(_WIN32_WCE)
return GetTickCount();
# else
return timeGetTime();
# endif
#endif
} }
/* /*

View File

@ -108,6 +108,16 @@ void fgPlatformDisplayWindow ( SFG_Window *window )
} }
unsigned long fgPlatformSystemTime ( void )
{
#if defined(_WIN32_WCE)
return GetTickCount();
#else
return timeGetTime();
#endif
}
void fgPlatformSleepForEvents( long msec ) void fgPlatformSleepForEvents( long msec )
{ {
MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLINPUT ); MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLINPUT );