From 174ee0e3d510cc1cacba3acb019a5742e834d038 Mon Sep 17 00:00:00 2001 From: "John F. Fay" Date: Sun, 29 Jan 2012 04:32:41 +0000 Subject: [PATCH] Splitting the platform-specific "fgSystemTime" code into its own functions git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1022 7f0cb862-5218-0410-a997-914c9d46530a --- src/Common/freeglut_main.c | 26 ++++++++++++++------------ src/mswin/freeglut_main_mswin.c | 10 ++++++++++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/Common/freeglut_main.c b/src/Common/freeglut_main.c index 980159d..b3bd7ee 100644 --- a/src/Common/freeglut_main.c +++ b/src/Common/freeglut_main.c @@ -72,6 +72,7 @@ struct GXKeyList gxKeyList; extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ); extern void fgPlatformDisplayWindow ( SFG_Window *window ); +extern unsigned long fgPlatformSystemTime ( void ); extern void fgPlatformSleepForEvents( long msec ); extern void fgPlatformProcessSingleEvent ( void ); extern void fgPlatformMainLoopPreliminaryWork ( void ); @@ -174,6 +175,16 @@ void fgPlatformDisplayWindow ( SFG_Window *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 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 * 32-bit, where the GLUT API return value is also overflowed. */ -unsigned long fgSystemTime(void) { -#if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY - struct timeval now; - 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 +unsigned long fgSystemTime(void) +{ + return fgPlatformSystemTime (); } /* diff --git a/src/mswin/freeglut_main_mswin.c b/src/mswin/freeglut_main_mswin.c index b04e9e0..be48b23 100644 --- a/src/mswin/freeglut_main_mswin.c +++ b/src/mswin/freeglut_main_mswin.c @@ -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 ) { MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLINPUT ); -- 1.7.10.4