Download presentation
Presentation is loading. Please wait.
Published byCharlotte Bell Modified over 9 years ago
1
Lecture 7 2D viewing 1 Lecture 7. 2D Viewing 2D viewing pipeline Clipping window, Normalization viewport transformation OpenGL 2D viewing functions Setup clipping window, viewport Display window managing Clipping algorithms –TWO-DIMENSIONAL POINT CLIPPING –LINE CLIPPING (1) Cohen-Sutherland Line Clipping (2) Liang-Barsky Line Clipping (3) Nicholl-Lee-Nicholl Line Cliping
2
Lecture 7 2D viewing 2 2D viewing pipeline Transformation vertices from MC to DC in five stages Construct WC scene using MC transformation Convert WC to VC Transform VC to NC Map NC to DC MC WCVCNCDC Clipping window (world window, or viewing window) The section of 2D scene selected for display Display window Viewport
3
Lecture 7 2D viewing 3
4
4
5
5
6
6
7
7 2D viewing pipeline transformations Construct WC scene using MC transformation Convert WC to VC Transform VC to NC Map NC to DC MC WCVCNCDC MC VC NC DC MC WC VC
8
Lecture 7 2D viewing 8 OpenGL 2D viewing functions OpenGL has no specific functions for 2D viewing. 2D viewing is a special case of 3D viewing glMatrixMode(GL-PROJECTION) Designate the projection matrix as the current matrix. Which is originally the identity matrix. Set the current matrix as identity matrix glLoadIdentity(); GLU clipping window function gluOrtho2D(xwmin, xwmax, ywmin, ywmax); OpenGL viewport function glViewport(xvmin, yvmin, vpWidth, vpHeight);
9
Lecture 7 2D viewing 9 GLUT display window functions Set Color mode, buffer mode glutInitDispalyMode(GLUT_SINGLE | GLUT_RGB); glClearColor(red, green, blue, alpha); glClearIndex(index); Display-window identifier glutSetWindow(windowID); currentWindowID = glutGetWindow(); Deleting a GLUT display window glutDestroyWindow(windowID); Relocate and resize glutPositionWindow(x, y); glutReshapeWindow(newWidth, newHeight); Display window relocate, and resize glutFullScreen(); glutReshapeFunc(winreshapFcn);
10
Lecture 7 2D viewing 10 Managing multiple GLUT display windows glutIconifyWindow(); glutSetIconTitle(“Icon Name”); glutSetWindowTitle(“New window name”); glutPopWindow(); glutPushWindow(); glutHideWindow(); glutShowWindow(); glutCreateSubWindow(……)
11
Lecture 7 2D viewing 11 Clipping algorithms Clipping: Generally, any procedure that identifies those portions of a picture that are either inside or outside of a specified region of space is referred as a clipping algorithm, or simply clipping. Types of Clipping: –Point clipping –Line Clipping (straight-lines Segments) –Area Clipping (Polygons, Curve-boundary Areas) –Curve Clipping –Text Clipping
12
Lecture 7 2D viewing 12 Point clipping Given a point P=(x, y), we display the point if the following inequalities are satisfied: xwmin <= x <= xwmax ywmin <= y <= ywmax where (xwmin, xwmax, ywmin, ywmax ) defines the clipping window position in WC or SC.
13
Lecture 7 2D viewing 13 Line Clipping Possible relationships between line positions and a clipping rectangle: 1.Totally out 2.Totally in 3.in-and-out 4.out-in-out
14
Lecture 7 2D viewing 14
15
Lecture 7 2D viewing 15
16
Lecture 7 2D viewing 16
17
Lecture 7 2D viewing 17
18
Lecture 7 2D viewing 18
19
Lecture 7 2D viewing 19
20
Lecture 7 2D viewing 20
21
Lecture 7 2D viewing 21
22
Lecture 7 2D viewing 22
23
Lecture 7 2D viewing 23
24
Lecture 7 2D viewing 24
25
Lecture 7 2D viewing 25
26
Lecture 7 2D viewing 26
27
Lecture 7 2D viewing 27
28
Lecture 7 2D viewing 28
29
Lecture 7 2D viewing 29
30
Lecture 7 2D viewing 30
31
Lecture 7 2D viewing 31
32
Lecture 7 2D viewing 32
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.