GL_VERTEXID(3G)
π GL_VERTEXID π
okay bestie so this is a page from the 3G manual section (that's the OpenGL-adjacent girlies, iykyk) and we're talking about one very specific little variable. she's small, she's an integer, she's the main character of your vertex shader. let's get into it β¨
πΈ NAME πΈ
gl_VertexID β literally just holds the index of the current vertex. that's it. that's her whole job π
π¦ DECLARATION π¦
in int gl_VertexID ;
(no cap, that stray space before the semicolon is in the original. we respect the original here π«Ά)
β DESCRIPTION β
so gl_VertexID is a vertex language input variable β a shader input, basically β and it holds an integer index for the vertex you're currently shading. think of it as the bouncer handing you a wristband number π
where does that number come from? two ways, bestie:
- implicitly generated by
glDrawArraysand other commands that do not reference the content of theGL_ELEMENT_ARRAY_BUFFERβ you didn't ask for an index, the system just handed you one π« - explicitly generated from the content of the
GL_ELEMENT_ARRAY_BUFFER, by commands such asglDrawElementsβ here the index comes straight out of the buffer π
and here's the lil detail that matters: for the glDrawElements forms that take a basevertex, gl_VertexID will have this value added to the index from the buffer. so it's not just the raw buffer index β basevertex gets folded in. noted. memorised. obsessed π₯
β¨ VERSION SUPPORT β¨
okay so the original had a whole giant table and we're gonna give you the same facts, just with more glitter and less spreadsheet energy π the columns are OpenGL Shading Language Versions, the row is gl_VertexID:
1.10β-(nope, not yet π)1.20β-(still nope π)1.30ββ(she's here!! π)1.40ββ1.50ββ3.30ββ4.00ββ4.10ββ4.20ββ4.30ββ4.40ββ4.50ββ
so tldr: gl_VertexID said "not me in 1.10 and 1.20" and then showed up for everything from 1.30 onward and never left. consistent queen π
π§ SEE ALSO π§
gl_InstanceID()
(her bestie. her ride-or-die. go read that one next, fr fr π«Ά)
π 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 Β© 2011-2014 Khronos Group
okay that's the whole page bestie, go forth and index your vertices π β¨
and a lil sign-off: this one came from [FIXME: source], dated 08/09/2021, and lives at GL_VERTEXID(3G) in the 3G manual. mwah ππ
π¦ 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