logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

gl_PrimitiveID - contains the index of the current primitive

Declaration

       // In tessellation control, tessellation evaluation, and
       // fragment shaders

       in int gl_PrimitiveID ;

       // In geometry shaders

       out int gl_PrimitiveID ;

Description

gl_PrimitiveID is 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_PrimitiveID is an output variable that is passed to the corresponding
       gl_PrimitiveID input variable in the fragment shader. If no geomery shader is present then gl_PrimitiveID
       in 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 to gl_PrimitiveID, the value of
       gl_PrimitiveID in the fragment shader is undefined.

Name

       gl_PrimitiveID - contains the index of the current primitive

See Also

gl_InstanceID(), gl_VertexID(), gl_PrimitiveIDIn()

Version Support

       ┌────────────────┬───────────────────────────────────────────────────────────────────────────────────┐
       │                │        OpenGLShadingLanguageVersion                                            │
       ├────────────────┼──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┤
       │ Function1.101.201.301.401.503.304.004.104.204.304.404.50 │
       │ Name           │      │      │      │      │      │      │      │      │      │      │      │      │
       ├────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
       │ gl_PrimitiveID │  -   │  -   │  -   │  -   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │
       │ (Fragment      │      │      │      │      │      │      │      │      │      │      │      │      │
       │ and            │      │      │      │      │      │      │      │      │      │      │      │      │
       │ Geometry       │      │      │      │      │      │      │      │      │      │      │      │      │
       │ Languages)     │      │      │      │      │      │      │      │      │      │      │      │      │
       ├────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
       │ gl_PrimitiveID │  -   │  -   │  -   │  -   │  -   │  -   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │
       │ (Tessellation  │      │      │      │      │      │      │      │      │      │      │      │      │
       │ Control and    │      │      │      │      │      │      │      │      │      │      │      │      │
       │ Evaluation     │      │      │      │      │      │      │      │      │      │      │      │      │
       │ Languages)     │      │      │      │      │      │      │      │      │      │      │      │      │
       └────────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┘

See Also