#include #include #include int t = 0; void myMouse(int b,int s,int x,int y) { if (b == GLUT_LEFT_BUTTON && s == GLUT_DOWN) { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); } } void display() { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_LINES); glColor3f(1, 0, 1); glPointSize(3); glVertex2i(-250, -250); glVertex2i(250, 250); glEnd(); glFlush(); glutSwapBuffers(); } void init() { glMatrixMode(GL_PROJECTION_MATRIX); glLoadIdentity(); glOrtho(-500, 500, -500, 500, -500, 500); glMatrixMode(GL_MODELVIEW); } int main() { //glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(500, 500); glutCreateWindow("line"); init(); glutDisplayFunc(display); glutMouseFunc(myMouse); glutMainLoop(); return 0; }