#define MAXSTARS 400
#define MAXPOS 10000
-#define MAXWARP 10
+#define MAXWARP 500
#define MAXANGLES 6000
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) {
}
}
-void RotatePoint(float *x, float *y, float rotation)
+static void RotatePoint(float *x, float *y, float rotation)
{
float tmpX, tmpY;
*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;
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;
}
}
-void ShowStars(void)
+static void ShowStars(void)
{
GLint n;
glDisable(GL_DITHER);
}
-void Reshape(int width, int height)
+static void Reshape(int width, int height)
{
windW = (GLint)width;
}
}
-void Draw(void)
+static void Draw(void)
{
MoveStars();
{
GLint i;
- doubleBuffer = GL_FALSE;
+ doubleBuffer = GL_TRUE;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-sb") == 0) {
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();
}