static void display();
static void keyboard(unsigned char key, int x, int y);
+static void idle();
/* XXX FIXME */
static Tentacle tentacle;
glutCreateWindow("ludu mice");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
+ glutIdleFunc(idle);
if (!init())
exit(1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- tentacle.draw();
+ tentacle.draw(glutGet(GLUT_ELAPSED_TIME));
glutSwapBuffers();
}
break;
}
}
+
+static void idle()
+{
+ glutPostRedisplay();
+}
}
void
-Tentacle::draw()
+Tentacle::draw(long time)
{
glLineWidth(2.0);
glBegin(GL_LINE_STRIP);
glColor3f(0.0, 0.0, 1.0);
for(size_t i=0; i<cpoints.size(); i++) {
- glVertex3f(cpoints[i].x, cpoints[i].y, cpoints[i].z);
+ float y = cpoints[i].y;
+ float offs = gph::noise(y, time * 0.0005 * y);
+ glVertex3f(cpoints[i].x + offs, y, cpoints[i].z + offs);
+
}
glEnd();
glBegin(GL_POINTS);
glColor3f(1.0, 0.0, 0.0);
for(size_t i=0; i<cpoints.size(); i++) {
- glVertex3f(cpoints[i].x, cpoints[i].y, 1.0);
+ float y = cpoints[i].y;
+ float offs = gph::noise(y, time * 0.0005 * y);
+ glVertex3f(cpoints[i].x + offs, y, cpoints[i].z + offs);
}
glEnd();
glEnable(GL_DEPTH_TEST);