// 1. Modify the following code so that a point appears randomly on the window every time // the LEFT mouse button is clicked. The program should terminate when either 'q' or // 'Q' are pressed. // 2. Modify the code so that you can toggle between clearing points after each click // or keeping them on the screen by pressing the 'c' or 'C' button. // 3. Modify the code so that you can toggle between two different colors for each // new point. #include #include #define WINDOW 300 GLint toggleClear=-1, toggleColor=-1; void myInit( void ) { // attributes glClearColor(1.0,1.0,1.0,0.0); // white glColor3f(0.0,0.0,0.0); glPointSize(4.0); //set up viewing glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0,WINDOW,0.0,WINDOW); glMatrixMode(GL_MODELVIEW); } void display ( void ) { glFlush(); } void mouse (int btn, int state, int x, int y) { } void keyboard (unsigned char key , int x, int y) { } void main(int argc , char ** argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize( WINDOW , WINDOW ); glutInitWindowPosition(90,90); glutCreateWindow("Interaction"); glutMouseFunc(mouse); glutKeyboardFunc(keyboard); glutDisplayFunc(display); myInit(); glutMainLoop(); }