Professional Documents
Culture Documents
Computer Graphics - Chapter 6
Computer Graphics - Chapter 6
Chapter 6
2D Viewing
Construct world-
Convert world- Transform viewing Map normalized
WC coordinate scene WC coordinates to
VC coordinates to
NC coordinates to DC
using modeling-
viewing normalized device
coordinate
coordinates coordinates coordinates
transformations
6.2 OpenGL 2D viewing functions
• Basic OpenGL library has no functions for 2D viewing. But the core library contains
a viewport function.
• The OpenGL Utility (GLU) does provide a 2D function for specifying the clipping
window, and GLUT functions for handling display windows.
OpenGL projection mode
• Before select a clipping window and a viewport in OpenGL, we need to establish
the appropriate mode for constructing the matrix to transform from world
coordinates to screen coordinates.
• To designate the project matrix as the current matrix
glMatrixMode(GL_PROJECTION);
glutInitWindowPosition(xTopLeft, yTopLeft);
glutInitWindowSize(dwWidth, dwHeight);
glutCreateWindow("Title of Display Window");
Setting the GLUT display-window mode and color
glutInitDisplayMode (mode);
glClearIndex (index);
glutSetWindow (windowID);
currentWindowID = glutGetWindow();
With multiple display windows open on the screen, to choose any display
window to be in front of all other windows
glutSetWindow(windowID);
glutPopWindow();