OpenGL in 2 Slides (cont.)
Displaying the same triangle polygon we showed before using OpenGL:
glClear( GL_COLOR_BUFFER_BIT );
gluLookAt( 0, -5, 0, 0, 0, 0, 0, 0, 1 );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB );
glutCreateWindow( "Simple Viewer" );
glClearColor( 0, 0, 0, 0 );
glutDisplayFunc( display );
glutReshapeFunc( reshape ); // not shown here
void reshape(int w, int h) {
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
gluPerspective(45, (float)w/h, 1, 5000);
glMatrixMode(GL_MODELVIEW);