GLVERTEXATTRIBPOINTE(3G)
π GLVERTEXATTRIBPOINTE(3G) β ok bestie, this is the glVertexAttribPointer glow-up
So you found a page in the OpenGL manual set (3G) and it's literally about telling the GPU where your vertex attribute data lives. No cap, this is one of those functions that ate and left no crumbs β every vertex you've ever drawn went through something like this. Let's go π
β¨ NAME β¨
glVertexAttribPointer β define an array of generic vertex attribute data. That's it, that's the whole vibe. π
π§ C SPECIFICATION π§
Three sisters, one page. Here's the whole squad:
void glVertexAttribPointer(GLuint index, GLint size, GLenum type,
GLboolean normalized, GLsizei stride,
const GLvoid * pointer);
void glVertexAttribIPointer(GLuint index, GLint size, GLenum type,
GLsizei stride, const GLvoid * pointer);
void glVertexAttribLPointer(GLuint index, GLint size, GLenum type,
GLsizei stride, const GLvoid * pointer);
Note the I one and the L one don't take a normalized arg β they said "not me, we're built different" π
π¦ PARAMETERS π¦
indexβ the index of the generic vertex attribute you're modifying. It's like the seat number in the group chat, everyone's gotta have their own.sizeβ how many components each generic vertex attribute has. Must be1,2,3,4. AND β plot twist β the symbolic constantGL_BGRAis also accepted, but only byglVertexAttribPointer. The initial value is4.typeβ the data type of each component in the array.GL_BYTE,GL_UNSIGNED_BYTE,GL_SHORT,GL_UNSIGNED_SHORT,GL_INT, andGL_UNSIGNED_INTare accepted byglVertexAttribPointerandglVertexAttribIPointer. On top of that,GL_HALF_FLOAT,GL_FLOAT,GL_DOUBLE,GL_FIXED,GL_INT_2_10_10_10_REV,GL_UNSIGNED_INT_2_10_10_10_REVandGL_UNSIGNED_INT_10F_11F_11F_REVare accepted byglVertexAttribPointer. AndGL_DOUBLEis also accepted byglVertexAttribLPointerβ in fact it's the only token accepted for thetypeparameter of that function. main character energy fr. The initial value isGL_FLOAT.normalizedβ forglVertexAttribPointeronly, bestie. Says whether fixed-point data values should be normalized (GL_TRUE) or converted directly as fixed-point values (GL_FALSE) when they're accessed. Choose wisely πstrideβ the byte offset between consecutive generic vertex attributes. Ifstrideis0, the generic vertex attributes are understood to be tightly packed in the array (iconic, no gaps, snug). The initial value is0.pointerβ specifies a offset of the first component of the first generic vertex attribute in the array, in the data store of the buffer currently bound to theGL_ARRAY_BUFFERtarget. The initial value is0.
πΈ DESCRIPTION πΈ
glVertexAttribPointer, glVertexAttribIPointer and glVertexAttribLPointer specify the location and data format of the array of generic vertex attributes at index index to use when rendering. That's the whole job. size says how many components per attribute and must be 1, 2, 3, 4, or GL_BGRA. type says the data type of each component, and stride says the byte stride from one attribute to the next β which is how you get to pack vertices and attributes into a single array, or store them in separate arrays. Both are valid, both slay. π«Ά
For glVertexAttribPointer, if normalized is set to GL_TRUE, that means values stored in an integer format get mapped to the range [-1,1] (for signed values) or [0,1] (for unsigned values) when they're accessed and converted to floating point. Otherwise, values are converted to floats directly, no normalization, no filter. πͺ
For glVertexAttribIPointer, only the integer types GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT are accepted. And values are always left as integer values. Periodt. π₯
glVertexAttribLPointer specifies state for a generic vertex attribute array associated with a shader attribute variable declared with 64-bit double precision components. type must be GL_DOUBLE. And index, size, and stride behave exactly as described for glVertexAttribPointer and glVertexAttribIPointer. Consistent queen. π
Now the part everyone forgets, so listen up:
Ifpointeris notNULL, a non-zero named buffer object must be bound to theGL_ARRAY_BUFFERtarget (seeglBindBuffer()), otherwise an error is generated. Not a vibe. π
pointer is treated as a byte offset into the buffer object's data store. The buffer object binding (GL_ARRAY_BUFFER_BINDING) is saved as generic vertex attribute array state (GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING) for index index.
When a generic vertex attribute array is specified, size, type, normalized, stride, and pointer are saved as vertex array state β in addition to the current vertex array buffer object binding. Everything gets remembered, she takes receipts π
To enable and disable a generic vertex attribute array, call glEnableVertexAttribArray() and
glDisableVertexAttribArray with index. If enabled, the generic vertex attribute array is used when glDrawArrays(), glMultiDrawArrays(), glDrawElements(), glMultiDrawElements(), or glDrawRangeElements() is called. That's the whole pipeline, bestie. π
π NOTES π
- Each generic vertex attribute array is initially disabled and isn't accessed when
glDrawElements(),glDrawRangeElements(),glDrawArrays(),glMultiDrawArrays(), orglMultiDrawElements()is called. Like a private account, nobody's seeing it until you enable it. π GL_UNSIGNED_INT_10F_11F_11F_REVis accepted fortypeonly if the GL version is4.4or higher. Version check first, always. β
π ERRORS π
Buckle up, this list is long but every single one matters:
GL_INVALID_VALUEis generated ifindexis greater than or equal toGL_MAX_VERTEX_ATTRIBS.GL_INVALID_VALUEis generated ifsizeis not1,2,3,4or (forglVertexAttribPointer),GL_BGRA.GL_INVALID_ENUMis generated iftypeis not an accepted value.GL_INVALID_VALUEis generated ifstrideis negative. (negative stride is not the move, bestie π«)GL_INVALID_OPERATIONis generated ifsizeisGL_BGRAandtypeis notGL_UNSIGNED_BYTE,GL_INT_2_10_10_10_REVorGL_UNSIGNED_INT_2_10_10_10_REV.GL_INVALID_OPERATIONis generated iftypeisGL_INT_2_10_10_10_REVorGL_UNSIGNED_INT_2_10_10_10_REVandsizeis not4orGL_BGRA.GL_INVALID_OPERATIONis generated iftypeisGL_UNSIGNED_INT_10F_11F_11F_REVandsizeis not3.GL_INVALID_OPERATIONis generated byglVertexAttribPointerifsizeisGL_BGRAandnoramlizedisGL_FALSE. (yes,noramlizedβ that spelling is straight from the source, I don't make the rules π)GL_INVALID_OPERATIONis generated if zero is bound to theGL_ARRAY_BUFFERbuffer object binding point and thepointerargument is notNULL. (see above, this is the consequence π)
π ASSOCIATED GETS π
Everything you can ask the GPU to spill about this state:
glGet()with argumentGL_MAX_VERTEX_ATTRIBSglGetVertexAttrib()with argumentsindexandGL_VERTEX_ATTRIB_ARRAY_ENABLEDglGetVertexAttrib()with argumentsindexandGL_VERTEX_ATTRIB_ARRAY_SIZEglGetVertexAttrib()with argumentsindexandGL_VERTEX_ATTRIB_ARRAY_TYPEglGetVertexAttrib()with argumentsindexandGL_VERTEX_ATTRIB_ARRAY_NORMALIZEDglGetVertexAttrib()with argumentsindexandGL_VERTEX_ATTRIB_ARRAY_STRIDEglGetVertexAttrib()with argumentsindexandGL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDINGglGet()with argumentGL_ARRAY_BUFFER_BINDINGglGetVertexAttribPointerv()with argumentsindexandGL_VERTEX_ATTRIB_ARRAY_POINTER
π VERSION SUPPORT π
(The original ships this as a whole table β I'm giving you the same tea in list form, no facts lost, promise π«Ά)
glVertexAttribIPointer
- OpenGL
2.0β-(nope) - OpenGL
2.1β-(nope) - OpenGL
3.0ββ - OpenGL
3.1ββ - OpenGL
3.2ββ - OpenGL
3.3ββ - OpenGL
4.0ββ - OpenGL
4.1ββ - OpenGL
4.2ββ - OpenGL
4.3ββ - OpenGL
4.4ββ - OpenGL
4.5ββ
glVertexAttribLPointer
- OpenGL
2.0β- - OpenGL
2.1β- - OpenGL
3.0β- - OpenGL
3.1β- - OpenGL
3.2β- - OpenGL
3.3β- - OpenGL
4.0β- - OpenGL
4.1ββ - OpenGL
4.2ββ - OpenGL
4.3ββ - OpenGL
4.4ββ - OpenGL
4.5ββ
glVertexAttribPointer
- OpenGL
2.0ββ - OpenGL
2.1ββ - OpenGL
3.0ββ - OpenGL
3.1ββ - OpenGL
3.2ββ - OpenGL
3.3ββ - OpenGL
4.0ββ - OpenGL
4.1ββ - OpenGL
4.2ββ - OpenGL
4.3ββ - OpenGL
4.4ββ - OpenGL
4.5ββ
Original table column header was just: function / feature name, then OpenGL Version 2.0 2.1 3.0 3.1 3.2 3.3 4.0 4.1 4.2 4.3 4.4 4.5. π
π SEE ALSO π
Go read these next, bestie:
glBindAttribLocation()glBindBuffer()glDisableVertexAttribArrayglDrawArrays()glDrawElements()glDrawRangeElements()glEnableVertexAttribArray()glMultiDrawArrays()glMultiDrawElements()glVertexAttrib()
π COPYRIGHT π
Copyright Β© 2003-2005 3Dlabs Inc. Ltd. Copyright Β© 2010-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 Β© 2003-2005 3Dlabs Inc. Ltd. Copyright Β© 2010-2014 Khronos Group
okay that's the whole page, you're officially caught up π This one came from [FIXME: source], dated 08/09/2021, and lives at GLVERTEXATTRIBPOINTE(3G) β go bind some buffers, bestie, you got this π
β¨
π¦ 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