// A.1 Sierpinski fill pad Program/* Two-dimen1_sierpinski gasket * // * generated using randomly selected vertices * // * And bisection */# include <Gl/glut. h> # include <windows. h> // no textbook. If rand () is not added, an error is returned. I do not know why/* you may have to change the include to <glut. h> orelsewhere depending on where it is stored on your system * // * glut. h usually has encoded ded for GL. H and Glu. H */void myinit (void) {/* attributes */glclearcolor (1.0, 1.0, 1.0, 1.0);/* white background */glcolor3f (1.0, 0.0, 0.0 ); /* draw in red * // * set up viewing * // * 50.0x50.0 camera coordinate window with origin lower left */glmatrixmode (gl_projection); glloadidentity (); gluortho2d (0.0, 50.0, 0.0, 50.0); glmatrixmode (gl_modelview);} void display (void) {/* a triangle */glfloat vertices [3] [2] = {0.0, 0.0}, {25.0, 50.0}, {50.0, 0.0}; int I, j, k; int rand ();/* standard random number generator */glfloat P [2] = {7.5, 5.0 }; /* an arbitrary initial point inside traingle */glclear (gl_color_buffer_bit);/* clear the window */glbegin (gl_points ); /* compute and plots 5000 new points */For (k = 0; k <5000; k ++) {J = rand () % 3; /* pick a vertex at random * // * compute point halfway between selected vertex and old point */P [0] = (P [0] + vertices [J] [0]) /2.0; P [1] = (P [1] + vertices [J] [1])/2.0;/* plot new point */glvertex2fv (p );} glend (); glflush ();/* clear buffers */} void main (INT argc, char ** argv) {/* standard glut initialization */gluinit (& argc, argv); gluinitdisplaymode (glu_single | glu_rgb);/* default, not needed */gluinitwindowsize (500,500);/* 500 × 500 pixel window */gluinitwindowposition ); /* place window top left on display */FIG ("Sierpinski gasket");/* window title */FIG (Display ); /* display callback invoked when window opened */myinit ();/* Set attributes */FIG ();/* enter event loop */}