next up previous contents index
Next: 2.6.1 Begin and End Up: 2 OpenGL Operation Previous: 2.5 GL Errors

2.6 Begin/End Paradigm


In the GL, most geometric objects are drawn by enclosing a series of coordinate sets that specify vertices and optionally normals, texture coordinates, and colors between Begin / End  pairs. There are ten geometric objects that are drawn this way: points, line segments, line segment loops, separated line segments, polygons, triangle strips, triangle fans, separated triangles, quadrilateral strips, and separated quadrilaterals.

Each vertex is specified with two, three, or four coordinates. In addition, a current normal, current texture coordinates, and current color may be used in processing each vertex. Normals are used by the GL in lighting calculations; the current normal is a three-dimensional vector that may be set by sending three coordinates that specify it. Texture coordinates determine how a texture image is mapped onto a primitive.

A color is associated with each vertex as it is specified. This associated color is either the current color or a color produced by lighting depending on whether or not lighting is enabled. Texture coordinates are similarly associated with each vertex. Figure 2.2 summarizes the association of auxiliary data with a transformed vertex to produce a processed vertex.

Figure 2.2: Association of current values with a vertex. The heavy lined boxes represent GL state.

The current values are part of GL state. Vertices and normals are transformed, colors may be affected or replaced by lighting, and texture coordinates are transformed and possibly affected by a texture coordinate generation function. The processing indicated for each current value is applied for each vertex that is sent to the GL.

The methods by which vertices, normals, texture coordinates, and colors are sent to the GL, as well as how normals are transformed and how vertices are mapped to the two-dimensional screen, are discussed later.

Before a color has been assigned to a vertex, the state required by a vertex is the vertex's coordinates, the current normal, and the current texture coordinates. Once color has been assigned, however, the current normal is no longer needed. Because color assignment is done vertex-by-vertex, a processed vertex comprises the vertex's coordinates, its assigned color, and its texture coordinates.

Figure 2.3: Primitive assembly and processing.

Figure 2.3 shows the sequence of operations that builds a primitive (point, line segment, or polygon) from a sequence of vertices. After a primitive is formed, it is clipped to a viewing volume. This may alter the primitive by altering vertex coordinates, texture coordinates, and color. In the case of a polygon primitive, clipping may insert new vertices into the primitive. The vertices defining a primitive to be rasterized have texture coordinates and color associated with them.

next up previous contents index
Next: 2.6.1 Begin and End Up: 2 OpenGL Operation Previous: 2.5 GL Errors

David Blythe
Sat Mar 29 02:23:21 PST 1997