use fmod() to prevent overflow of angle variable
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 30 Sep 2005 15:03:33 +0000 (15:03 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 30 Sep 2005 15:03:33 +0000 (15:03 +0000)
progs/demos/gears.c

index 679fac44893f260a269f8a1481d734a67ef9e780..ab9bc007421f3d37aecc25abd0cd8e3cb3ed862c 100644 (file)
@@ -234,7 +234,9 @@ idle(void)
   dt = t - t0;
   t0 = t;
 
-  angle += 70.0 * dt;  /* 90 degrees per second */
+  angle += 70.0 * dt;  /* 70 degrees per second */
+  angle = fmod(angle, 360.0); /* prevents eventual overflow */
+
   glutPostRedisplay();
 }