CPTR 425 Computer Graphics Assignment 1

Write a C or C++ program using the OpenGL library that allows the user to select four two-dimensional points within a window. The first three points represent the vertices of a triangle, and the fourth point represents a seed point. The program proceeds by generating additional points as outlined in the following pseudocode:

   v1, v2, and v3 are the points representing the vertices of a triangle;
   s is the seed point;
   n is initially 256;
   for (int i = 0; i < n; i++) {
        //  Select one of the three vertex points at random.
        p = a randomly chosen point from v1, v2, and v3;

        //  Compute the midpoint of the seed point and this
        //  randomly chosen point
        m = the midpoint of s and p;

        //  Render this new point and then make it the new seed point  
        draw(m);
        s = m;
   }
Allow the user to move at any time any of the four original points. Double n each time the user presses the U key, but do not let n exceed 1,048,576. Cut n in half each time the user presses the D key, but do not allow n to fall below 256.

Clear the window and redraw its contents after each user interaction. This means your program will need to redraw all the points after the user moves a point or adjusts the point count.

You will know when your program is working correctly when you see the shape of a Sierpinksi Triangle (see http://en.wikipedia.org/wiki/Sierpinski_triangle).

When you are finished, submit your C or C++ source file(s) to eclass.e.southern.edu.