fadeout
[censuslogo] / src / main.c
index 0807e5d..23b9878 100644 (file)
@@ -122,17 +122,20 @@ void display(void)
        long msec = glutGet(GLUT_ELAPSED_TIME) - start_time;
        float t = (float)msec / 1000.0f;
        float a[2], b[2], dt;
-       float anim;
+       float anim, alpha;
 
        glClear(GL_COLOR_BUFFER_BIT);
 
        glLineWidth(5.0);
 
        anim = fmod(t / 6.0f, LOOPTIME);
+       alpha = 1.0f - ((anim - (LOOPTIME - 0.2)) / 0.2f);
+       if(alpha < 0.0f) alpha = 0.0f;
+       if(alpha > 1.0f) alpha = 1.0f;
 
        dt = (anim > 1.0f ? 1.0f : anim) / (float)(nverts - 1);
 
-       glColor3f(1, 1, 1);
+       glColor4f(1, 1, 1, alpha);
        for(i=0; i<nverts-1; i++) {
                float t0 = (float)i * dt;
                float t1 = (float)(i + 1) * dt;
@@ -156,6 +159,16 @@ void display(void)
        glColor4f(0.8, 0, 0, 2.0 * (anim - 1.0f) / (LOOPTIME - 1.0f));
        draw_disc(0, 0, 0.14, 24);
 
+       if(alpha < 1.0f) {
+               glBegin(GL_QUADS);
+               glColor4f(0, 0, 0, 1.0f - alpha);
+               glVertex2f(-1, -1);
+               glVertex2f(1, -1);
+               glVertex2f(1, 1);
+               glVertex2f(-1, 1);
+               glEnd();
+       }
+
        glDisable(GL_BLEND);
 
        glutSwapBuffers();