The options for primitive type are the following. In these examples, assume that v0, v1, and so on, have been specified between a Begin and End pair, similar to the following.
Draws a series of (unconnected) line segments. Segments are drawn between v0 and v1, between v2 and v3, and so on. If n is odd, the last vertex is ignored.
Draws a polygon using the points v0,..., vn as vertices. Three vertices must exist, or nothing is drawn. In addition, the polygon specified must not intersect itself and must be convex. If the vertices do not satisfy these conditions, the results are unpredictable.
primitive type=TRIANGLES
Draws a series of (disconnected) triangles using vertices v0, v1, v2, then v3, v4, v5, and so on. If the number of vertices is not an exact multiple of 3, the final one or two vertices are ignored.
primitive type=LINE_STRIP
Draws a line segment from v0 to v1, then from v1 to v2, and so on. Therefore, n vertices specify n–1 line segments. Nothing is drawn unless there is more than one vertex. There are no restrictions on the vertices describing a line strip; the lines can intersect arbitrarily.
primitive type=LINE_LOOP
Draws a series of quadrilaterals (four-sided polygons) using vertices v0, v1, v2, v3, then v4, v5, v6, v7, and so on. If the number of vertices is not a multiple of 4, the final one, two, or three vertices are ignored.
primitive type=QUAD_STRIP
Draws a series of quadrilaterals (four-sided polygons) beginning with v0, v1, v3, v2, then v2, v3, v5, v4, then v4, v5, v7, v6, and so on. The number of vertices must be at least 4 before anything is drawn, and if odd, the final vertex is ignored.
primitive type=TRIANGLE_STRIP
Draws a series of triangles (three-sided polygons) using vertices v0, v1, v2, then v2, v1, v3 (note the order), then v2, v3, v4, and so on. The ordering is to ensure that the triangles are all drawn with the same orientation so that the strip can correctly form part of a surface. There must be at least three vertices for anything to be drawn.
primitive type=TRIANGLE_FAN
Same as TRIANGLE_STRIP, except that the vertices are v0, v1, v2, then v0, v2, v3, then v0, v3, v4, and so on.
The first section of the script creates a display list named shape. Inside this display list, a polygon is defined using six vertices.
Note that all the z-coordinates are zero, which makes sure the polygon lies in a plane. Polygons that do not lie in a plane can cause unpredictable results.
Polygon (left) and Triangles (right)
where n is the number of pixels. Note that this might not be the actual number of pixels rendered, depending on other settings such as anti-aliasing and your hardware configuration.
where n is the number of pixels. The argument n must be larger than zero and is, by default, one.
Line Stipple(factor, pattern)
Factor is a stretching factor. Pattern is a 16-bit integer that turns pixels on or off. Use Enable(LINE_STIPPLE) to turn the effect on.
The factor argument expands each binary digit to two digits. In the example above, Line Stipple(2, 255) would result in 00000000000000001111111111111111.
Stipples
where face can be FRONT, BACK, or FRONT_AND_BACK, and mode can be POINT, LINE, or FILL.
Points, Line, and Fill Modes
For example, the following script creates a display list that defines a triangle. This display list is used three times in conjunction with Translate, Rotate, and Color commands to draw triangles in three positions. In addition, the Polygon Mode command changes the drawing mode of each triangle. Note there is no explicit call to the FILL mode, since it is the default.
The following table dissects the script, showing how the Translate and Rotate commands accumulate to manipulate a single display list.
Creates a display list named shape that holds vertices for the triangles. All the z vertices are zero since this is a two dimensional scene
Polygon Offset (factor, units)
To enable offsetting, use Enable(POLYGON_OFFSET_FILL), Enable(POLYGON_OFFSET_LINE), or Enable(POLYGON_OFFSET_POINT), depending on the desired mode. The actual offset values are calculated as m*(factor)+r*(units), where m is the maximum depth slope of the polygon and r is the smallest value guaranteed to produce a resolvable difference in window coordinate depth values. Start with Polygon Offset(1,1) if you need this.
An example of Polygon Offset is in the Surface Plot platform, when a surface and a mesh are displayed on top of each other, or a surface and contours displayed on top of each other. In either case, the surface would interfere with the lines if the lines were not moved closer or the surface moved farther from the viewer.
Vertex adds a vertex to the list
Color changes the current color
Normal sets the normal vector coordinates
Edge Flag controls drawing of edges
Material sets material properties
Eval Coord and Eval Point generate coordinates
Call List executes a display list.