util: Fix descriptors for R32_FLOAT and R32G32_FLOAT formats.
[mesa.git] / progs / samples / star.c
index 62d7d8548524fddd2c4cff094ef048917aab48c1..2c44ebfd49e95fec5a56a7030a23eb38a8b7cf72 100644 (file)
@@ -45,7 +45,7 @@ enum {
 
 #define MAXSTARS 400
 #define MAXPOS 10000
-#define MAXWARP 10
+#define MAXWARP 500
 #define MAXANGLES 6000
 
 
@@ -67,19 +67,19 @@ starRec stars[MAXSTARS];
 float sinTable[MAXANGLES];
 
 
-float Sin(float angle)
+static float Sin(float angle)
 {
 
     return (sinTable[(GLint)angle]);
 }
 
-float Cos(float angle)
+static float Cos(float angle)
 {
 
     return (sinTable[((GLint)angle+(MAXANGLES/4))%MAXANGLES]);
 }
 
-void NewStar(GLint n, GLint d)
+static void NewStar(GLint n, GLint d)
 {
 
     if (rand()%4 == 0) {
@@ -101,7 +101,7 @@ void NewStar(GLint n, GLint d)
     }
 }
 
-void RotatePoint(float *x, float *y, float rotation)
+static void RotatePoint(float *x, float *y, float rotation)
 {
     float tmpX, tmpY;
 
@@ -111,10 +111,17 @@ void RotatePoint(float *x, float *y, float rotation)
     *y = tmpY;
 }
 
-void MoveStars(void)
+static void MoveStars(void)
 {
     float offset;
     GLint n;
+    static double t0 = -1.;
+    double t, dt;
+    t = glutGet(GLUT_ELAPSED_TIME) / 1000.;
+    if (t0 < 0.)
+       t0 = t;
+    dt = 85.*(t - t0);
+    t0 = t;
 
     offset = speed * 60.0;
 
@@ -122,17 +129,20 @@ void MoveStars(void)
        stars[n].x[1] = stars[n].x[0];
        stars[n].y[1] = stars[n].y[0];
        stars[n].z[1] = stars[n].z[0];
-       stars[n].x[0] += stars[n].offsetX;
-       stars[n].y[0] += stars[n].offsetY;
-       stars[n].z[0] -= offset;
-        stars[n].rotation += stars[n].offsetR;
+       stars[n].x[0] += stars[n].offsetX*dt;
+       stars[n].y[0] += stars[n].offsetY*dt;
+       stars[n].z[0] -= offset*dt;
+        stars[n].rotation += stars[n].offsetR*dt;
         if (stars[n].rotation > MAXANGLES) {
             stars[n].rotation = 0.0;
        }
+        else if (stars[n].rotation < 0.0) {
+           stars[n].rotation += 360.0;
+        }
     }
 }
 
-GLenum StarPoint(GLint n)
+static GLenum StarPoint(GLint n)
 {
     float x0, y0, x1, y1, width;
     GLint i;
@@ -180,7 +190,7 @@ GLenum StarPoint(GLint n)
     }
 }
 
-void ShowStars(void)
+static void ShowStars(void)
 {
     GLint n;
 
@@ -219,7 +229,7 @@ static void Init(void)
     glDisable(GL_DITHER);
 }
 
-void Reshape(int width, int height)
+static void Reshape(int width, int height)
 {
 
     windW = (GLint)width;
@@ -250,7 +260,7 @@ static void Key(unsigned char key, int x, int y)
     }
 }
 
-void Draw(void)
+static void Draw(void)
 {
 
     MoveStars();
@@ -293,7 +303,11 @@ static GLenum Args(int argc, char **argv)
     return GL_TRUE;
 }
 
-void GLUTCALLBACK glut_post_redisplay_p(void)
+#if !defined(GLUTCALLBACK)
+#define GLUTCALLBACK
+#endif
+
+static void GLUTCALLBACK glut_post_redisplay_p(void)
 {
       glutPostRedisplay();
 }