#include void display(void) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glColor3d(1.0, 0.0, 0.0); glVertex2d(-0.7, -0.7); glColor3d(0.0, 1.0, 0.0); glVertex2d(0.7, -0.7); glColor3d(0.0, 0.0, 1.0); glVertex2d(0.0, 0.7); glEnd(); } void keyboard(unsigned char key, int x, int y) { if (key == '\033') exit(0); } void resize(int w, int h) { glViewport(0, 0, w, h); glLoadIdentity(); glOrtho(-w / 200.0, w / 200.0, -h / 200.0, h / 200.0, -1.0, 1.0); } int main(int argc, char *argv[]) { glutInitWindowPosition(100, 100); glutInitWindowSize(320, 240); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA); glutCreateWindow(argv[0]); glClearColor(1.0, 1.0, 1.0, 0.0); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutReshapeFunc(resize); glutMainLoop(); return 0; }