1GLBEGIN(3G) OpenGL Manual GLBEGIN(3G)
2
3
4
6 glBegin - delimit the vertices of a primitive or a group of like
7 primitives
8
10 void glBegin(GLenum mode);
11
13 mode
14 Specifies the primitive or primitives that will be created from
15 vertices presented between glBegin and the subsequent glEnd(). Ten
16 symbolic constants are accepted: GL_POINTS, GL_LINES,
17 GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP,
18 GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, and GL_POLYGON.
19
21 void glEnd(void);
22
24 glBegin and glEnd() delimit the vertices that define a primitive or a
25 group of like primitives. glBegin accepts a single argument that
26 specifies in which of ten ways the vertices are interpreted. Taking n
27 as an integer count starting at one, and N as the total number of
28 vertices specified, the interpretations are as follows:
29
30 GL_POINTS
31 Treats each vertex as a single point. Vertex n defines point n. N
32 points are drawn.
33
34 GL_LINES
35 Treats each pair of vertices as an independent line segment.
36 Vertices 2 n - 1 and 2 n define line n. N 2 lines are drawn.
37
38 GL_LINE_STRIP
39 Draws a connected group of line segments from the first vertex to
40 the last. Vertices n and n + 1 define line n. N - 1 lines are
41 drawn.
42
43 GL_LINE_LOOP
44 Draws a connected group of line segments from the first vertex to
45 the last, then back to the first. Vertices n and n + 1 define line
46 n. The last line, however, is defined by vertices N and 1. N lines
47 are drawn.
48
49 GL_TRIANGLES
50 Treats each triplet of vertices as an independent triangle.
51 Vertices 3 n - 2, 3 n - 1, and 3 n define triangle n. N 3
52 triangles are drawn.
53
54 GL_TRIANGLE_STRIP
55 Draws a connected group of triangles. One triangle is defined for
56 each vertex presented after the first two vertices. For odd n,
57 vertices n, n + 1, and n + 2 define triangle n. For even n,
58 vertices n + 1, n, and n + 2 define triangle n. N - 2 triangles
59 are drawn.
60
61 GL_TRIANGLE_FAN
62 Draws a connected group of triangles. One triangle is defined for
63 each vertex presented after the first two vertices. Vertices 1, n +
64 1, and n + 2 define triangle n. N - 2 triangles are drawn.
65
66 GL_QUADS
67 Treats each group of four vertices as an independent quadrilateral.
68 Vertices 4 n - 3, 4 n - 2, 4 n - 1, and 4 n define
69 quadrilateral n. N 4 quadrilaterals are drawn.
70
71 GL_QUAD_STRIP
72 Draws a connected group of quadrilaterals. One quadrilateral is
73 defined for each pair of vertices presented after the first pair.
74 Vertices 2 n - 1, 2 n, 2 n + 2, and 2 n + 1 define
75 quadrilateral n. N 2 - 1 quadrilaterals are drawn. Note that the
76 order in which vertices are used to construct a quadrilateral from
77 strip data is different from that used with independent data.
78
79 GL_POLYGON
80 Draws a single, convex polygon. Vertices 1 through N define this
81 polygon.
82
83 Only a subset of GL commands can be used between glBegin and glEnd().
84 The commands are glVertex(), glColor(), glSecondaryColor(), glIndex(),
85 glNormal(), glFogCoord(), glTexCoord(), glMultiTexCoord(),
86 glVertexAttrib(), glEvalCoord(), glEvalPoint(), glArrayElement(),
87 glMaterial(), and glEdgeFlag(). Also, it is acceptable to use
88 glCallList() or glCallLists() to execute display lists that include
89 only the preceding commands. If any other GL command is executed
90 between glBegin and glEnd(), the error flag is set and the command is
91 ignored.
92
93 Regardless of the value chosen for mode, there is no limit to the
94 number of vertices that can be defined between glBegin and glEnd().
95 Lines, triangles, quadrilaterals, and polygons that are incompletely
96 specified are not drawn. Incomplete specification results when either
97 too few vertices are provided to specify even a single primitive or
98 when an incorrect multiple of vertices is specified. The incomplete
99 primitive is ignored; the rest are drawn.
100
101 The minimum specification of vertices for each primitive is as follows:
102 1 for a point, 2 for a line, 3 for a triangle, 4 for a quadrilateral,
103 and 3 for a polygon. Modes that require a certain multiple of vertices
104 are GL_LINES (2), GL_TRIANGLES (3), GL_QUADS (4), and GL_QUAD_STRIP
105 (2).
106
108 GL_INVALID_ENUM is generated if mode is set to an unaccepted value.
109
110 GL_INVALID_OPERATION is generated if glBegin is executed between a
111 glBegin and the corresponding execution of glEnd().
112
113 GL_INVALID_OPERATION is generated if glEnd() is executed without being
114 preceded by a glBegin.
115
116 GL_INVALID_OPERATION is generated if a command other than glVertex(),
117 glColor(), glSecondaryColor(), glIndex(), glNormal(), glFogCoord(),
118 glTexCoord(), glMultiTexCoord(), glVertexAttrib(), glEvalCoord(),
119 glEvalPoint(), glArrayElement(), glMaterial(), glEdgeFlag(),
120 glCallList(), or glCallLists() is executed between the execution of
121 glBegin and the corresponding execution glEnd().
122
123 Execution of glEnableClientState(), glDisableClientState(),
124 glEdgeFlagPointer(), glFogCoordPointer(), glTexCoordPointer(),
125 glColorPointer(), glSecondaryColorPointer(), glIndexPointer(),
126 glNormalPointer(), glVertexPointer(), glVertexAttribPointer(),
127 glInterleavedArrays(), or glPixelStore() is not allowed after a call to
128 glBegin and before the corresponding call to glEnd(), but an error may
129 or may not be generated.
130
132 glArrayElement(), glCallList(), glCallLists(), glColor(), glEdgeFlag(),
133 glEvalCoord(), glEvalPoint(), glFogCoord(), glIndex(), glMaterial(),
134 glMultiTexCoord(), glNormal(), glSecondaryColor(), glTexCoord(),
135 glVertex(), glVertexAttrib()
136
138 Copyright © 1991-2006 Silicon Graphics, Inc. This document is licensed
139 under the SGI Free Software B License. For details, see
140 http://oss.sgi.com/projects/FreeB/.
141
143 opengl.org
144
145
146
147opengl.org 06/10/2014 GLBEGIN(3G)