ARB prog parser: fix parameter binding type
[mesa.git] / progs / demos / bounce.c
index 876ce589dc9ff8fa4e812a4dea91f65c47d061ae..436bc7d1fb880813b711aba663f5ee5f0ce19262 100644 (file)
@@ -1,33 +1,12 @@
-/* $Id: bounce.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
 
 /*
- * Bouncing ball demo.  Color index mode only!
+ * Bouncing ball demo.
  *
  * This program is in the public domain
  *
  * Brian Paul
- */
-
-/* Conversion to GLUT by Mark J. Kilgard */
-
-/*
- * $Log: bounce.c,v $
- * Revision 1.1  1999/08/19 00:55:40  jtg
- * Initial revision
- *
- * Revision 3.3  1999/03/18 08:16:14  joukj
- *
- *     cmpstr needs string.h to included to avoid warnings
- *
- * Revision 3.2  1998/11/28 01:13:02  brianp
- * now sets an initial window position and size
- *
- * Revision 3.1  1998/11/28 01:06:57  brianp
- * now works in RGB mode by default
- *
- * Revision 3.0  1998/02/14 18:42:29  brianp
- * initial rev
  *
+ * Conversion to GLUT by Mark J. Kilgard
  */
 
 
 GLboolean IndexMode = GL_FALSE;
 GLuint Ball;
 GLenum Mode;
-GLfloat Zrot = 0.0, Zstep = 6.0;
+GLfloat Zrot = 0.0, Zstep = 180.0;
 GLfloat Xpos = 0.0, Ypos = 1.0;
-GLfloat Xvel = 0.2, Yvel = 0.0;
+GLfloat Xvel = 2.0, Yvel = 0.0;
 GLfloat Xmin = -4.0, Xmax = 4.0;
 GLfloat Ymin = -3.8, Ymax = 4.0;
-GLfloat G = -0.1;
+GLfloat G = -9.8;
 
 static GLuint 
 make_ball(void)
@@ -81,9 +60,9 @@ make_ball(void)
         glColor3f(1, 1, 1);
       }
 
-      x = COS(b) * COS(a);
-      y = SIN(b) * COS(a);
-      z = SIN(a);
+      x = radius * COS(b) * COS(a);
+      y = radius * SIN(b) * COS(a);
+      z = radius * SIN(a);
       glVertex3f(x, y, z);
 
       x = radius * COS(b) * COS(a + da);
@@ -170,10 +149,17 @@ static void
 idle(void)
 {
   static float vel0 = -100.0;
+  static double t0 = -1.;
+  double t, dt;
+  t = glutGet(GLUT_ELAPSED_TIME) / 1000.;
+  if (t0 < 0.)
+     t0 = t;
+  dt = t - t0;
+  t0 = t;
 
-  Zrot += Zstep;
+  Zrot += Zstep*dt;
 
-  Xpos += Xvel;
+  Xpos += Xvel*dt;
   if (Xpos >= Xmax) {
     Xpos = Xmax;
     Xvel = -Xvel;
@@ -184,8 +170,8 @@ idle(void)
     Xvel = -Xvel;
     Zstep = -Zstep;
   }
-  Ypos += Yvel;
-  Yvel += G;
+  Ypos += Yvel*dt;
+  Yvel += G*dt;
   if (Ypos < Ymin) {
     Ypos = Ymin;
     if (vel0 == -100.0)
@@ -195,7 +181,7 @@ idle(void)
   glutPostRedisplay();
 }
 
-void 
+static void 
 visible(int vis)
 {
   if (vis == GLUT_VISIBLE)