Page 48 - Computer Graphics Handout
P. 48

after they have been placed on the GPU. All OpenGL geometric primitives are variants of points, line segments, and triangular
          polygons. A point can be displayed as a single pixel or a small group of pixels. Finite sections of lines between two vertices, called
          line segments—in contrast to lines that are infinite in extent—are of great importance in geometry and computer graphics. You can
          use line segments to define approximations to curves, or you can use a sequence of line segments to connect data values for a
          graph. You can also use line segments to display the edges of closed objects, such as polygons, that have interiors.
          Consequently, it is often helpful to think in terms of both vertices and line segments.
          If  we  wish  to  display  points  or  line  segments,  we  have  a  few  choices  in  OpenGL  (Figure  2.7).  The  primitives  and  their  type
          specifications include the following:
          Points (GL_POINTS) Each vertex is displayed at a size of at least one pixel.
          Line segments (GL_LINES) The line-segment type causes successive pairs of vertices

          to be interpreted as the endpoints of individual segments. Note that successive segments usually are disconnected because the
          vertices are processed on a pairwise basis.
          Polylines (GL_LINE_STRIP, GL_LINE_LOOP) If successive vertices (and line segments) are to be connected, we can use the line strip,
          or polyline form. Many curves can be approximated via a suitable polyline. If we wish the polyline to be closed, we
          can locate the final vertex in the same place as the first, or we can use the GL_LINE_ LOOP type, which will draw a line segment from
          the final vertex to the first, thus creating a closed path.













          2.4.1 Polygon Basics
          Line segments and polylines can model the edges of objects, but closed objects have interiors (Figure 2.8). Usually we reserve the
                                                                                                         8
          name polygon for an object that has a border that can be described by a line loop but also has a well-defined interior .
          Polygons play a special role in computer graphics because we can display them rapidly and use them to approximate arbitrary
                                                                                                                9
          surfaces. The performance of graphics systems is characterized by the number of polygons per second that can be rendered . We
          can render a polygon in a variety of ways:We can render only its edges, we can render its interior with a solid color or a pattern, and
          we can render or not render the edges, as shown in Figure 2.9. Although the outer edges of a polygon are defined easily by an
          ordered list of vertices, if the interior is not well defined, then the list of vertices may not be rendered at all or rendered in an
          undesirable manner. Three properties will ensure that a polygon will be displayed correctly: It must be simple, convex, and flat.
          In two dimensions, as long as no two edges of a polygon cross each other, we have a simple polygon. As we can see in Figure 2.10,
          simple two-dimensional polygons have well-defined interiors. Although the locations of the vertices determine whether

















          8  The term fill area is sometimes used instead of polygon.
          9
            Measuring polygon rendering speeds involves both the number of vertices and the number of
          pixels inside.
                                                              48
   43   44   45   46   47   48   49   50   51   52   53