glBeginglEnd
glBegin glEnd are functions used in OpenGL, a cross-language, cross-platform API for rendering 2D and 3D vector graphics. Specifically, glBegin and glEnd delimit a block of commands that describe a primitive, such as a point, line, or polygon. The glBegin function takes an argument that specifies the type of primitive to be drawn. Common primitive types include GL_POINTS, GL_LINES, GL_TRIANGLES, GL_QUADS, and GL_POLYGON. After glBegin is called, a series of glVertex calls are made to define the vertices of the primitive. Each glVertex call specifies the coordinates of a vertex. Once all vertices for the primitive have been defined, glEnd is called to signal the end of the primitive definition. The OpenGL pipeline then processes these vertices to render the specified primitive on the screen. This immediate mode rendering was a common way to draw graphics in older versions of OpenGL. Modern OpenGL, however, generally uses vertex buffer objects (VBOs) and shaders for more efficient and flexible rendering, largely replacing the direct use of glBegin and glEnd. While still supported for backward compatibility in some contexts, developers are encouraged to transition to the newer programmable pipeline.