/* 1. Compile and run this code. 2. Modify the code so that it renders to ONE viewport, which is just the left half of the WINDOW. 3. Modify the code so that it renders to TWO viewports, each of which is half the WINDOW size. */ #include #include using namespace std; #define WINDOW 400 void myInit() { glClearColor(1.0,1.0,1.0,0.0); glColor3f(0.0,0.0,0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0,400,0,400); glMatrixMode(GL_MODELVIEW); } void display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f(100,100); glVertex2f(300,100); glVertex2f(300,300); glVertex2f(100,300); glEnd(); glFlush(); } int main (int argc , char **argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(WINDOW,WINDOW); glutInitWindowPosition(100.0,100.0); glutCreateWindow("Viewport"); glutDisplayFunc(display); myInit(); glutMainLoop(); return 0; }