aboutsummaryrefslogtreecommitdiffstats
path: root/progs/samples/star.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-01-08 23:52:01 +0000
committerBrian Paul <[email protected]>2005-01-08 23:52:01 +0000
commitc1065ee977f70042e54a930a6cd3af819d4a9806 (patch)
tree45053d22bc302bde8c627e9e8d2cc174a17c844a /progs/samples/star.c
parent0261042bebe4c17afd3b581fac0ab5274dac3740 (diff)
compute reasonable animate rate (Marcelo Magallon)
Diffstat (limited to 'progs/samples/star.c')
-rw-r--r--progs/samples/star.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/progs/samples/star.c b/progs/samples/star.c
index 570c3e19f9d..2cf470e2a2f 100644
--- a/progs/samples/star.c
+++ b/progs/samples/star.c
@@ -45,7 +45,7 @@ enum {
#define MAXSTARS 400
#define MAXPOS 10000
-#define MAXWARP 10
+#define MAXWARP 500
#define MAXANGLES 6000
@@ -115,6 +115,13 @@ 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,10 +129,10 @@ 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;
}
@@ -296,6 +303,10 @@ static GLenum Args(int argc, char **argv)
return GL_TRUE;
}
+#if !defined(GLUTCALLBACK)
+#define GLUTCALLBACK
+#endif
+
void GLUTCALLBACK glut_post_redisplay_p(void)
{
glutPostRedisplay();