From: Eleni Maria Stea Date: Sun, 19 Apr 2020 11:49:07 +0000 (+0300) Subject: Added idle func animation X-Git-Url: https://eleni.mutantstargoat.com/git/?p=ludumice;a=commitdiff_plain;h=ff092b42b596fe15a0e1122beb4fc5c8ae032b7c Added idle func animation --- diff --git a/src/main.cc b/src/main.cc index c5ebc84..38ec59e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -9,6 +9,7 @@ static void cleanup(); static void display(); static void keyboard(unsigned char key, int x, int y); +static void idle(); /* XXX FIXME */ static Tentacle tentacle; @@ -22,6 +23,7 @@ int main(int argc, char **argv) glutCreateWindow("ludu mice"); glutDisplayFunc(display); glutKeyboardFunc(keyboard); + glutIdleFunc(idle); if (!init()) exit(1); @@ -56,7 +58,7 @@ static void display() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - tentacle.draw(); + tentacle.draw(glutGet(GLUT_ELAPSED_TIME)); glutSwapBuffers(); } @@ -70,3 +72,8 @@ static void keyboard(unsigned char key, int x, int y) break; } } + +static void idle() +{ + glutPostRedisplay(); +} diff --git a/src/tentacle.cc b/src/tentacle.cc index 7a69c29..ceb5e43 100644 --- a/src/tentacle.cc +++ b/src/tentacle.cc @@ -25,13 +25,16 @@ Tentacle::add_control_point(const Vec3 &point) } 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