Added FREEGLUT_LIB_PRAGMAS to control MS library pragmas, and fixed NOMINMAX define.
[freeglut] / src / freeglut_main.c
index c78dab8..2189c41 100644 (file)
@@ -120,7 +120,7 @@ static void fghReshapeWindow ( SFG_Window *window, int width, int height )
 
         if ( window->Parent == NULL )
         {
-            if ( ! window->IsMenu && !window->State.IsGameMode )
+            if ( ! window->IsMenu && (window != fgStructure.GameModeWindow) )
             {
                 w += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
                 h += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 +
@@ -301,46 +301,32 @@ static void fghCheckTimers( void )
     }
 }
 
-/*
- * Elapsed Time
- */
-long fgElapsedTime( void )
-{
-    if ( fgState.Time.Set )
-    {
-#if TARGET_HOST_POSIX_X11
-        struct timeval now;
-        long elapsed;
-
-        gettimeofday( &now, NULL );
-
-        elapsed = (now.tv_usec - fgState.Time.Value.tv_usec) / 1000;
-        elapsed += (now.tv_sec - fgState.Time.Value.tv_sec) * 1000;
-
-        return elapsed;
-#elif TARGET_HOST_MS_WINDOWS
-#    if defined(_WIN32_WCE)
-        return GetTickCount() - fgState.Time.Value;
-#    else
-        return timeGetTime() - fgState.Time.Value;
-#    endif
-#endif
-    }
-    else
-    {
+/* Platform-dependent time in milliseconds, as an unsigned 32-bit integer.
+ * This value wraps every 49.7 days, but integer overflows cancel
+ * 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_POSIX_X11
-        gettimeofday( &fgState.Time.Value, NULL );
+    struct timeval now;
+    gettimeofday( &now, NULL );
+    return now.tv_usec/1000 + now.tv_sec*1000;
 #elif TARGET_HOST_MS_WINDOWS
 #    if defined(_WIN32_WCE)
-        fgState.Time.Value = GetTickCount();
+    return GetTickCount();
 #    else
-        fgState.Time.Value = timeGetTime ();
+    return timeGetTime();
 #    endif
 #endif
-        fgState.Time.Set = GL_TRUE ;
-
-        return 0 ;
-    }
+}
+  
+/*
+ * Elapsed Time
+ */
+long fgElapsedTime( void )
+{
+    return (long) (fgSystemTime() - fgState.Time);
 }
 
 /*
@@ -489,7 +475,7 @@ static void fghSleepForEvents( void )
             fgWarning ( "freeglut select() error: %d", errno );
     }
 #elif TARGET_HOST_MS_WINDOWS
-    MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLEVENTS );
+    MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLINPUT );
 #endif
 }