gl_PrimitiveID

From OpenGL Reference
Jump to navigation Jump to search

Contains the index of the current primitive.

Declaration[edit]

Description[edit]

gl_PrimitiveIDis a tessellation control, tessellation evaluation and fragment language input variable. For the tessellation control and tessellation evaluation languages, it holds the number of primitives processed by the shader since the current set of rendering primitives was started. The first primitive processed by the drawing command is numbered zero and the primitive ID counter is incremented after every individual point, line or triangle primitive is processed. For triangles drawn in point or line mode, the primitive ID counter is incremented only once, even through multiple points or lines may actually be drawn. Restarting a primitive topology using the primitive restart index has no effect on the primitive ID counter.

In the geometry language,gl_PrimitiveIDis an output variable that is passed to the correspondinggl_PrimitiveIDinput variable in the fragment shader. If no geomery shader is present thengl_PrimitiveIDin the fragment language behaves identically as it would in the tessellation control and evaluation languages. If a geometry shader is present but does not write togl_PrimitiveID, the value ofgl_PrimitiveIDin the fragment shader is undefined.


Version Support[edit]

gl_PrimitiveID(Fragment and Geometry Languages) 1.5+
gl_PrimitiveID(Tessellation Control and Evaluation Languages) 4.0+

See Also[edit]

 gl_InstanceID , gl_VertexID , gl_PrimitiveIDIn 


Copyright[edit]

Copyright© 2011-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.