1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE book PUBLIC
"-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3 "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
4 <refentry id=
"glBegin">
9 <holder>Silicon Graphics, Inc.
</holder>
12 <refentrytitle>glBegin
</refentrytitle>
13 <manvolnum>3G
</manvolnum>
16 <refname>glBegin
</refname>
17 <refpurpose>delimit the vertices of a primitive or a group of like primitives
</refpurpose>
19 <refsynopsisdiv><title>C Specification
</title>
22 <funcdef>void
<function>glBegin
</function></funcdef>
23 <paramdef>GLenum
<parameter>mode
</parameter></paramdef>
27 <!-- eqn: ignoring delim $$ -->
28 <refsect1 id=
"parameters"><title>Parameters
</title>
31 <term><parameter>mode
</parameter></term>
34 Specifies the primitive or primitives that will be created from vertices
35 presented between
<function>glBegin
</function> and the subsequent
<citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry>.
36 Ten symbolic constants are accepted:
37 <constant>GL_POINTS
</constant>,
38 <constant>GL_LINES
</constant>,
39 <constant>GL_LINE_STRIP
</constant>,
40 <constant>GL_LINE_LOOP
</constant>,
41 <constant>GL_TRIANGLES
</constant>,
42 <constant>GL_TRIANGLE_STRIP
</constant>,
43 <constant>GL_TRIANGLE_FAN
</constant>,
44 <constant>GL_QUADS
</constant>,
45 <constant>GL_QUAD_STRIP
</constant>, and
46 <constant>GL_POLYGON
</constant>.
52 <refsynopsisdiv><title>C Specification
</title>
55 <funcdef>void
<function>glEnd
</function></funcdef>
56 <paramdef><parameter>void
</parameter></paramdef>
60 <refsect1 id=
"description"><title>Description
</title>
62 <function>glBegin
</function> and
<citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry> delimit the vertices that define a primitive or
63 a group of like primitives.
64 <function>glBegin
</function> accepts a single argument that specifies in which of ten ways the
65 vertices are interpreted.
67 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>
68 as an integer count starting at one,
70 <inlineequation><mml:math><mml:mi mathvariant=
"italic">N
</mml:mi></mml:math></inlineequation>
71 as the total number of vertices specified,
72 the interpretations are as follows:
76 <term><constant>GL_POINTS
</constant></term>
79 Treats each vertex as a single point.
81 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>
83 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>.
84 <inlineequation><mml:math><mml:mi mathvariant=
"italic">N
</mml:mi></mml:math></inlineequation>
90 <term><constant>GL_LINES
</constant></term>
93 Treats each pair of vertices as an independent line segment.
95 <inlineequation><mml:math>
100 <mml:mi mathvariant=
"italic">n
</mml:mi>
104 </mml:math></inlineequation>
106 <inlineequation><mml:math>
110 <mml:mo>⁢</mml:mo>
111 <mml:mi mathvariant=
"italic">n
</mml:mi>
113 </mml:math></inlineequation>
115 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>.
116 <inlineequation><mml:math>
119 <mml:mi mathvariant=
"italic">N
</mml:mi>
122 </mml:math></inlineequation>
128 <term><constant>GL_LINE_STRIP
</constant></term>
131 Draws a connected group of line segments from the first vertex
134 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>
136 <inlineequation><mml:math>
139 <mml:mi mathvariant=
"italic">n
</mml:mi>
143 </mml:math></inlineequation>
145 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>.
146 <inlineequation><mml:math>
149 <mml:mi mathvariant=
"italic">N
</mml:mi>
153 </mml:math></inlineequation>
159 <term><constant>GL_LINE_LOOP
</constant></term>
162 Draws a connected group of line segments from the first vertex
164 then back to the first.
166 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>
168 <inlineequation><mml:math>
171 <mml:mi mathvariant=
"italic">n
</mml:mi>
175 </mml:math></inlineequation>
177 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>.
178 The last line, however, is defined by vertices
179 <inlineequation><mml:math><mml:mi mathvariant=
"italic">N
</mml:mi></mml:math></inlineequation>
181 <inlineequation><mml:math>
184 </mml:math></inlineequation>.
185 <inlineequation><mml:math><mml:mi mathvariant=
"italic">N
</mml:mi></mml:math></inlineequation>
191 <term><constant>GL_TRIANGLES
</constant></term>
194 Treats each triplet of vertices as an independent triangle.
196 <inlineequation><mml:math>
200 <mml:mo>⁢</mml:mo>
201 <mml:mi mathvariant=
"italic">n
</mml:mi>
205 </mml:math></inlineequation>,
206 <inlineequation><mml:math>
210 <mml:mo>⁢</mml:mo>
211 <mml:mi mathvariant=
"italic">n
</mml:mi>
215 </mml:math></inlineequation>,
217 <inlineequation><mml:math>
221 <mml:mo>⁢</mml:mo>
222 <mml:mi mathvariant=
"italic">n
</mml:mi>
224 </mml:math></inlineequation>
226 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>.
227 <inlineequation><mml:math>
230 <mml:mi mathvariant=
"italic">N
</mml:mi>
233 </mml:math></inlineequation>
239 <term><constant>GL_TRIANGLE_STRIP
</constant></term>
242 Draws a connected group of triangles. One triangle is defined for each
243 vertex presented after the first two vertices. For odd
244 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>,
246 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>,
247 <inlineequation><mml:math>
250 <mml:mi mathvariant=
"italic">n
</mml:mi>
254 </mml:math></inlineequation>,
256 <inlineequation><mml:math>
259 <mml:mi mathvariant=
"italic">n
</mml:mi>
263 </mml:math></inlineequation>
265 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>.
267 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>,
269 <inlineequation><mml:math>
272 <mml:mi mathvariant=
"italic">n
</mml:mi>
276 </mml:math></inlineequation>,
277 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>,
279 <inlineequation><mml:math>
282 <mml:mi mathvariant=
"italic">n
</mml:mi>
286 </mml:math></inlineequation>
288 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>.
289 <inlineequation><mml:math>
292 <mml:mi mathvariant=
"italic">N
</mml:mi>
296 </mml:math></inlineequation>
303 <term><constant>GL_TRIANGLE_FAN
</constant></term>
306 Draws a connected group of triangles.
307 One triangle is defined for each vertex presented after the first two vertices.
309 <inlineequation><mml:math>
312 </mml:math></inlineequation>,
313 <inlineequation><mml:math>
316 <mml:mi mathvariant=
"italic">n
</mml:mi>
320 </mml:math></inlineequation>,
322 <inlineequation><mml:math>
325 <mml:mi mathvariant=
"italic">n
</mml:mi>
329 </mml:math></inlineequation>
331 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>.
332 <inlineequation><mml:math>
335 <mml:mi mathvariant=
"italic">N
</mml:mi>
339 </mml:math></inlineequation>
345 <term><constant>GL_QUADS
</constant></term>
348 Treats each group of four vertices as an independent quadrilateral.
350 <inlineequation><mml:math>
354 <mml:mo>⁢</mml:mo>
355 <mml:mi mathvariant=
"italic">n
</mml:mi>
359 </mml:math></inlineequation>,
360 <inlineequation><mml:math>
364 <mml:mo>⁢</mml:mo>
365 <mml:mi mathvariant=
"italic">n
</mml:mi>
369 </mml:math></inlineequation>,
370 <inlineequation><mml:math>
374 <mml:mo>⁢</mml:mo>
375 <mml:mi mathvariant=
"italic">n
</mml:mi>
379 </mml:math></inlineequation>,
381 <inlineequation><mml:math>
385 <mml:mo>⁢</mml:mo>
386 <mml:mi mathvariant=
"italic">n
</mml:mi>
388 </mml:math></inlineequation>
390 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>.
391 <inlineequation><mml:math>
394 <mml:mi mathvariant=
"italic">N
</mml:mi>
397 </mml:math></inlineequation>
398 quadrilaterals are drawn.
403 <term><constant>GL_QUAD_STRIP
</constant></term>
406 Draws a connected group of quadrilaterals.
407 One quadrilateral is defined for each pair of vertices presented
408 after the first pair.
410 <inlineequation><mml:math>
414 <mml:mo>⁢</mml:mo>
415 <mml:mi mathvariant=
"italic">n
</mml:mi>
419 </mml:math></inlineequation>,
420 <inlineequation><mml:math>
424 <mml:mo>⁢</mml:mo>
425 <mml:mi mathvariant=
"italic">n
</mml:mi>
427 </mml:math></inlineequation>,
428 <inlineequation><mml:math>
432 <mml:mo>⁢</mml:mo>
433 <mml:mi mathvariant=
"italic">n
</mml:mi>
437 </mml:math></inlineequation>,
439 <inlineequation><mml:math>
443 <mml:mo>⁢</mml:mo>
444 <mml:mi mathvariant=
"italic">n
</mml:mi>
448 </mml:math></inlineequation>
450 <inlineequation><mml:math><mml:mi mathvariant=
"italic">n
</mml:mi></mml:math></inlineequation>.
451 <inlineequation><mml:math>
452 <!-- eqn: N/2 - 1:-->
455 <mml:mi mathvariant=
"italic">N
</mml:mi>
461 </mml:math></inlineequation>
462 quadrilaterals are drawn.
463 Note that the order in which vertices are used to construct a quadrilateral
464 from strip data is different from that used with independent data.
469 <term><constant>GL_POLYGON
</constant></term>
475 <inlineequation><mml:math>
478 </mml:math></inlineequation>
480 <inlineequation><mml:math><mml:mi mathvariant=
"italic">N
</mml:mi></mml:math></inlineequation>
487 Only a subset of GL commands can be used between
<function>glBegin
</function> and
<citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry>.
489 <citerefentry><refentrytitle>glVertex
</refentrytitle></citerefentry>,
490 <citerefentry><refentrytitle>glColor
</refentrytitle></citerefentry>,
491 <citerefentry><refentrytitle>glSecondaryColor
</refentrytitle></citerefentry>,
492 <citerefentry><refentrytitle>glIndex
</refentrytitle></citerefentry>,
493 <citerefentry><refentrytitle>glNormal
</refentrytitle></citerefentry>,
494 <citerefentry><refentrytitle>glFogCoord
</refentrytitle></citerefentry>,
495 <citerefentry><refentrytitle>glTexCoord
</refentrytitle></citerefentry>,
496 <citerefentry><refentrytitle>glMultiTexCoord
</refentrytitle></citerefentry>,
497 <citerefentry><refentrytitle>glVertexAttrib
</refentrytitle></citerefentry>,
498 <citerefentry><refentrytitle>glEvalCoord
</refentrytitle></citerefentry>,
499 <citerefentry><refentrytitle>glEvalPoint
</refentrytitle></citerefentry>,
500 <citerefentry><refentrytitle>glArrayElement
</refentrytitle></citerefentry>,
501 <citerefentry><refentrytitle>glMaterial
</refentrytitle></citerefentry>, and
502 <citerefentry><refentrytitle>glEdgeFlag
</refentrytitle></citerefentry>.
504 it is acceptable to use
505 <citerefentry><refentrytitle>glCallList
</refentrytitle></citerefentry> or
506 <citerefentry><refentrytitle>glCallLists
</refentrytitle></citerefentry> to execute
507 display lists that include only the preceding commands.
508 If any other GL command is executed between
<function>glBegin
</function> and
<citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry>,
509 the error flag is set and the command is ignored.
512 Regardless of the value chosen for
<parameter>mode
</parameter>,
513 there is no limit to the number of vertices that can be defined
514 between
<function>glBegin
</function> and
<citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry>.
518 and polygons that are incompletely specified are not drawn.
519 Incomplete specification results when either too few vertices are
520 provided to specify even a single primitive or when an incorrect multiple
521 of vertices is specified. The incomplete primitive is ignored; the rest are drawn.
524 The minimum specification of vertices
525 for each primitive is as follows:
529 4 for a quadrilateral,
531 Modes that require a certain multiple of vertices are
532 <constant>GL_LINES
</constant> (
2),
533 <constant>GL_TRIANGLES
</constant> (
3),
534 <constant>GL_QUADS
</constant> (
4),
535 and
<constant>GL_QUAD_STRIP
</constant> (
2).
538 <refsect1 id=
"errors"><title>Errors
</title>
540 <constant>GL_INVALID_ENUM
</constant> is generated if
<parameter>mode
</parameter> is set to an unaccepted value.
543 <constant>GL_INVALID_OPERATION
</constant> is generated if
<function>glBegin
</function> is executed between a
544 <function>glBegin
</function>
545 and the corresponding execution of
<citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry>.
548 <constant>GL_INVALID_OPERATION
</constant> is generated if
<citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry> is executed without being
549 preceded by a
<function>glBegin
</function>.
552 <constant>GL_INVALID_OPERATION
</constant> is generated if a command other than
553 <citerefentry><refentrytitle>glVertex
</refentrytitle></citerefentry>,
554 <citerefentry><refentrytitle>glColor
</refentrytitle></citerefentry>,
555 <citerefentry><refentrytitle>glSecondaryColor
</refentrytitle></citerefentry>,
556 <citerefentry><refentrytitle>glIndex
</refentrytitle></citerefentry>,
557 <citerefentry><refentrytitle>glNormal
</refentrytitle></citerefentry>,
558 <citerefentry><refentrytitle>glFogCoord
</refentrytitle></citerefentry>,
559 <citerefentry><refentrytitle>glTexCoord
</refentrytitle></citerefentry>,
560 <citerefentry><refentrytitle>glMultiTexCoord
</refentrytitle></citerefentry>,
561 <citerefentry><refentrytitle>glVertexAttrib
</refentrytitle></citerefentry>,
562 <citerefentry><refentrytitle>glEvalCoord
</refentrytitle></citerefentry>,
563 <citerefentry><refentrytitle>glEvalPoint
</refentrytitle></citerefentry>,
564 <citerefentry><refentrytitle>glArrayElement
</refentrytitle></citerefentry>,
565 <citerefentry><refentrytitle>glMaterial
</refentrytitle></citerefentry>,
566 <citerefentry><refentrytitle>glEdgeFlag
</refentrytitle></citerefentry>,
567 <citerefentry><refentrytitle>glCallList
</refentrytitle></citerefentry>, or
568 <citerefentry><refentrytitle>glCallLists
</refentrytitle></citerefentry> is executed between
569 the execution of
<function>glBegin
</function> and the corresponding
570 execution
<citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry>.
574 <citerefentry><refentrytitle>glEnableClientState
</refentrytitle></citerefentry>,
575 <citerefentry><refentrytitle>glDisableClientState
</refentrytitle></citerefentry>,
576 <citerefentry><refentrytitle>glEdgeFlagPointer
</refentrytitle></citerefentry>,
577 <citerefentry><refentrytitle>glFogCoordPointer
</refentrytitle></citerefentry>,
578 <citerefentry><refentrytitle>glTexCoordPointer
</refentrytitle></citerefentry>,
579 <citerefentry><refentrytitle>glColorPointer
</refentrytitle></citerefentry>,
580 <citerefentry><refentrytitle>glSecondaryColorPointer
</refentrytitle></citerefentry>,
581 <citerefentry><refentrytitle>glIndexPointer
</refentrytitle></citerefentry>,
582 <citerefentry><refentrytitle>glNormalPointer
</refentrytitle></citerefentry>,
583 <citerefentry><refentrytitle>glVertexPointer
</refentrytitle></citerefentry>,
584 <citerefentry><refentrytitle>glVertexAttribPointer
</refentrytitle></citerefentry>,
585 <citerefentry><refentrytitle>glInterleavedArrays
</refentrytitle></citerefentry>, or
586 <citerefentry><refentrytitle>glPixelStore
</refentrytitle></citerefentry> is not allowed after a call to
<function>glBegin
</function> and before
587 the corresponding call to
<citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry>,
588 but an error may or may not be generated.
591 <refsect1 id=
"seealso"><title>See Also
</title>
593 <citerefentry><refentrytitle>glArrayElement
</refentrytitle></citerefentry>,
594 <citerefentry><refentrytitle>glCallList
</refentrytitle></citerefentry>,
595 <citerefentry><refentrytitle>glCallLists
</refentrytitle></citerefentry>,
596 <citerefentry><refentrytitle>glColor
</refentrytitle></citerefentry>,
597 <citerefentry><refentrytitle>glEdgeFlag
</refentrytitle></citerefentry>,
598 <citerefentry><refentrytitle>glEvalCoord
</refentrytitle></citerefentry>,
599 <citerefentry><refentrytitle>glEvalPoint
</refentrytitle></citerefentry>,
600 <citerefentry><refentrytitle>glFogCoord
</refentrytitle></citerefentry>,
601 <citerefentry><refentrytitle>glIndex
</refentrytitle></citerefentry>,
602 <citerefentry><refentrytitle>glMaterial
</refentrytitle></citerefentry>,
603 <citerefentry><refentrytitle>glMultiTexCoord
</refentrytitle></citerefentry>,
604 <citerefentry><refentrytitle>glNormal
</refentrytitle></citerefentry>,
605 <citerefentry><refentrytitle>glSecondaryColor
</refentrytitle></citerefentry>,
606 <citerefentry><refentrytitle>glTexCoord
</refentrytitle></citerefentry>,
607 <citerefentry><refentrytitle>glVertex
</refentrytitle></citerefentry>,
608 <citerefentry><refentrytitle>glVertexAttrib
</refentrytitle></citerefentry>
611 <refsect1 id=
"Copyright"><title>Copyright
</title>
613 Copyright
<trademark class=
"copyright"></trademark> 1991-
2006
614 Silicon Graphics, Inc. This document is licensed under the SGI
615 Free Software B License. For details, see
616 <ulink url=
"http://oss.sgi.com/projects/FreeB/">http://oss.sgi.com/projects/FreeB/
</ulink>.