Viewport Transformation The viewport indicates the size and the location of the available screen area. glViewport (x, y, width, height) § x - The lower-left corner of the viewport rectangle, in pixels. The default is (0,0). § y - The lower-left corner of the viewport rectangle, in pixels. The default is (0,0). § width - The width of the viewport. When an OpenGL context is first attached to a window, width and height are set to the dimensions of that window. § height - The height of the viewport. When an OpenGL context is first attached to a window, width and height are set to the dimensions of that window.
More Viewport Transformation § Window size & viewport size has to cooperate with the projection transformation. § Aspect ratio and distortion ratio = width / height; //cast int to float glViewport (x, y, width, height); gluOrtho2D (left, right, bottom, top); // and gluOrtho
General Reading § Read Hearn Baker ch5 p232-p252 for 2D geometric transformation § Read Hearn Baker ch6 p297-p305 for 2D viewing § Extend your understanding of 2D transformation and viewing to 3D § Read Red Book(pdf): ch3
Reading for Project 1 § Required Reading: Red Book: ch3 p73-p78, shows you the underlying OpenGL matrix multiplication scheme. This is essential, though not obvious. § Tips: there is no 2D translation, rotation and scale in OpenGL. Instead, think of your 2D scene as projected onto x-y plane § You may not have to set up your camera and call gluLookAt in your 1st 2D project, but do read about 3D viewing for your future projects § Required Reading: Red Book: ch3 p86-p92 § Tips: Do not mess with glDepthRange, if you are not confident about Z-depth value § Suggested Reading: example 3-4 to understand matrix stack § Suggested Reading: example 3-6, 3-7 to assembly everything in Chapter 3 § A summary of GLUT functions you may need to create a display application: Hearn Baker p341