GL_PRIMITIVEID(3G)
π NAME π
Okay so bestie, this page is GL_PRIMITIVEID(3G) β the header is literally wearing a [FIXME: manual] sticker, but the tea is simple: gl_PrimitiveID contains the index of the current primitive. That's it. That's the whole vibe. β¨
πΈ DECLARATION πΈ
Copy these exactly, no freestyling:
// In tessellation control, tessellation evaluation, and
// fragment shaders
in int gl_PrimitiveID ;
// In geometry shaders
out int gl_PrimitiveID ;
π¦ DESCRIPTION π¦
So 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 gets 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 though 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 geometry 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. π
β οΈ That last bit is the important one: geometry shader present + no write to gl_PrimitiveID = undefined value in the fragment shader. Not a vibe. π
β¨ VERSION SUPPORT β¨
Okay so the table had OpenGL Shading Language Version across the top and Function Name down the side, and hereβs the exact β / - situation, no table but all the receipts:
gl_PrimitiveID(Fragment and Geometry Languages) β1.10:-,1.20:-,1.30:-,1.40:-,1.50:β,3.30:β,4.00:β,4.10:β,4.20:β,4.30:β,4.40:β,4.50:β.gl_PrimitiveID(Tessellation Control and Evaluation Languages) β1.10:-,1.20:-,1.30:-,1.40:-,1.50:-,3.30:-,4.00:β,4.10:β,4.20:β,4.30:β,4.40:β,4.50:β.
π SEE ALSO π
gl_InstanceID()gl_VertexID()gl_PrimitiveIDIn()
π COPYRIGHT π
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/.
π COPYRIGHT π (again, because the page says it twice)
Copyright Β© 2011-2014 Khronos Group
okay thatβs the whole GL_PRIMITIVEID(3G) situation, bestie π signing off from the [FIXME: source] corner on 08/09/2021 β byeee π«Ά
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms