#include #include #include void display() { glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.8,0.7,0.9); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); glRectf(0.2,0.5,0.4,0.7); glBegin(GL_TRIANGLES); glVertex2f(0.0,0.5); glVertex2f(-0.5,0.0); glVertex2f(0.5,0.0); glEnd(); glFlush(); } void reshape(int width, int height) { glViewport(0, 0, (GLint) width, (GLint) height); } void init() { glClearColor(0, 0, 0, 0); } void hit(unsigned char i, int a, int b) { switch(i){ case 'q': exit(1); break; } glutPostRedisplay(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB); glutInitWindowSize(500,500); glutInitWindowPosition(0,0); glutCreateWindow("First Program"); init(); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(hit); glutMainLoop(); }