CGChapter Three
CGChapter Three
• Computer Graphics with Open GL, 4th edition, Hearn, Baker & Carithers.
2
Chapter Three
Graphics Output Primitives
3
Content
4
Definitions
7
Screen Coordinates
8
Screen Coordinates
9
Screen Coordinates
13
OpenGl Point Functions
• Where the asterisk (*) indicates that suffix codes are required
for this function.
• The argument of the glBegin function is used to identify the kind of output
primitive that is to be displayed, and glEnd takes no arguments.
• For point plotting, the argument of the glBegin function is the symbolic
constant GL POINTS.
glBegin (GL_POINTS);
glVertex* ( );
glEnd ( );
15
OpenGl Point Functions
• Coordinate positions in OpenGL can be given in two, three, or
four dimensions.
18
OpenGl Point Functions
19
OpenGl Point Functions
23
OpenGl Line Functions
• Figure 4(c) shows the display of our endpoint list when we select this line
option, using the code
glBegin (GL_LINE_LOOP);
glVertex2iv (p1);
glVertex2iv (p2);
glVertex2iv (p3);
glVertex2iv (p4);
glVertex2iv (p5);
glEnd ( );
25
OpenGl Curve Functions
• However, all these routines are more involved than the basic
primitives we introduce in this chapter.
27
OpenGl Curve Functions
28
Fill-Area Primitives
29
Fill-Area Primitives
30
Fill-Area Primitives
31
Fill-Area Primitives
32
Polygon Fill Areas
34
OpenGL Polygon Fill-Area Functions
35
OpenGL Polygon Fill-Area Functions
• There are six different symbolic constants that we can use as the
argument in the glBegin function to describe polygon fill areas.
• These six primitive constants allow us to display a single fill polygon, a set
of unconnected fill polygons, or a set of connected fill polygons.
36
OpenGL Polygon Fill-Area Functions
37
OpenGL Polygon Fill-Area Functions
• Suffix codes for glRect specify the coordinate data type and whether
coordinates are to be expressed as array elements.
• These codes are i (for integer), s (for short), f (for float), d (for double),
and v (for vector). The rectangle is displayed with edges parallel to the
xy coordinate axes.
38
OpenGL Polygon Fill-Area Functions
39
OpenGL Polygon Fill-Area Functions
40
OpenGL Polygon Fill-Area Functions
41
OpenGL Polygon Fill-Area Functions
42
OpenGL Polygon Fill-Area Functions
• For this example, we assume that we have a list of six points,
labeled p1 through p6, specifying two-dimensional polygon
vertex positions in a counterclockwise ordering.
• Each of the points is represented as an array of (x, y)
coordinate values:
glBegin (GL_POLYGON);
glVertex2iv (p1);
glVertex2iv (p2);
glVertex2iv (p3);
glVertex2iv (p4);
glVertex2iv (p5);
glVertex2iv (p6);
glEnd ( );
43
OpenGL Polygon Fill-Area Functions
47
OpenGL Polygon Fill-Area Functions
48
OpenGL Polygon Fill-Area Functions
51