#include #include #include #include void display(void) { // clear all pixels in frame buffer glClear(GL_COLOR_BUFFER_BIT); // draw a red wireframe of a teapot glColor3f (1.0, 0.0, 0.0); // (red,green,blue) colour components glutWireTeapot(0.6); // start processing buffered OpenGL routines glFlush (); } void init (void) { // select clearing color (for glClear) glClearColor (1.0, 1.0, 1.0, 0.0); // initialize view (simple orthographic projection) glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); } // create a single buffered 250x250 pixels big colour window int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (250, 250); glutInitWindowPosition (100, 100); glutCreateWindow("My first OpenGL program"); init (); // initialise view glutDisplayFunc(display); // draw scene glutMainLoop(); return 0; // ANSI C requires main to return int }