## 2.1. OpenGL PrimitivesIn OpenGL, applications render primitives by specifying a primitive type and a sequence of vertices with associated data. The primitive type determines how OpenGL interprets and renders the sequence of vertices. ## 2.1.1. Primitive TypesOpenGL provides ten different primitive types for drawing points, lines, and polygons, as shown in Figure 2-1. ## Figure 2-1. OpenGL primitive types.OpenGL interprets the vertices and renders each primitive using the following rules: `GL_POINTS`Use this primitive type to render mathematical points. OpenGL renders a point for each vertex specified.`GL_LINES`Use this primitive to draw unconnected line segments. OpenGL draws a line segment for each group of two vertices. If the application specifies n vertices, OpenGL renders n/2 line segments. If n is odd, OpenGL ignores the final vertex.`GL_LINE_STRIP`Use this primitive to draw a sequence of connected line segments. OpenGL renders a line segment between the first and second vertices, between the second and third, between the third and fourth, and so on. If the application specifies n vertices, OpenGL renders n1 line segments.`GL_LINE_LOOP`Use this primitive to close a line strip. OpenGL renders this primitive like a`GL_LINE_STRIP`with the addition of a closing line segment between the final and first vertices.`GL_TRIANGLES`Use this primitive to draw individual triangles. OpenGL renders a triangle for each group of three vertices. If your application specifies n vertices, OpenGL renders n/3 triangles. If n isn't a multiple of 3, OpenGL ignores the excess vertices.`GL_TRIANGLE_STRIP`Use this primitive to draw a sequence of triangles that share edges. OpenGL renders a triangle using the first, second, and third vertices, and then another using the second, third, and fourth vertices, and so on. If the application specifies n vertices, OpenGL renders n2 connected triangles. If n is less than 3, OpenGL renders nothing.`GL_TRIANGLE_FAN`Use this primitive to draw a fan of triangles that share edges and also share a vertex. Each triangle shares the first vertex specified. If the application specifies a sequence of vertices v, OpenGL renders a triangle using v_{0}, v_{1}, and v_{2}; another triangle using v_{0}, v_{2}, and v_{3}; another triangle using v_{0}, v_{3}, and v_{4}; and so on. If the application specifies n vertices, OpenGL renders n2 connected triangles. If n is less than 3, OpenGL renders nothing.`GL_QUADS`Use this primitive to draw individual convex quadrilaterals. OpenGL renders a quadrilateral for each group of four vertices. If the application specifies n vertices, OpenGL renders n/4 quadrilaterals. If n isn't a multiple of 4, OpenGL ignores the excess vertices.`GL_QUAD_STRIP`Use this primitive to draw a sequence of quadrilaterals that share edges. If the application specifies a sequence of vertices v, OpenGL renders a quadrilateral using v_{0}, v_{1}, v_{3}, and v_{2}; another quadrilateral using v_{2}, v_{3}, v_{5}, and v_{4}; and so on. If the application specifies n vertices, OpenGL renders (n-2)/2 quadrilaterals. If n is less than 4, OpenGL renders nothing.`GL_POLYGON`Use`GL_POLYGON`to draw a single filled convex n-gon primitive. OpenGL renders an n-sided polygon, where n is the number of vertices specified by the application. If n is less than 3, OpenGL renders nothing.
For ## 2.1.2. Vertex SharingNote that You could render a two-quadrilateral |

flylib.com © 2008-2017.

If you may any questions please contact us: flylib@qtcs.net

If you may any questions please contact us: flylib@qtcs.net