GLCOLORPOINTER(3G)
π GLCOLORPOINTER β bestie, it's in the 3G manual section and it's giving "define an array of colors" β¨
okay so picture this: you're out here rendering, and you need a whole ARRAY of colors, not just one sad little color. that's what glColorPointer is for. it tells OpenGL where your colors live and what shape they're in. let's get into it π
πΈ C SPECIFICATION πΈ
void glColorPointer( GLint size,
GLenum type,
GLsizei stride,
const GLvoid *ptr )
like yes bestie that's the whole signature, no notes π
β¨ PARAMETERS β¨
sizeβ how many components per color. has to be3or4, no in-between. the initial value is4.typeβ the data type of each color component in the array. the accepted symbolic constants areGL_BYTE,GL_UNSIGNED_BYTE,GL_SHORT,GL_UNSIGNED_SHORT,GL_INT,GL_UNSIGNED_INT,GL_FLOAT, andGL_DOUBLE. the initial value isGL_FLOAT.strideβ the byte offset between consecutive colors. ifstrideis0(which is the initial value, btw), the colors are understood to be tightly packed in the array. the initial value is0.ptrβ a pointer to the first component of the first color element in the array. literally just where it all starts π«Ά
π¦ DESCRIPTION π¦
glColorPointer specifies the location and data of an array of color components to use when rendering. size says how many components per color, and it must be 3 or 4. type says the data type of each color component, and stride specifies the byte stride from one color to the next β which is the whole trick that lets vertices and attributes be packed into a single array, or stored in separate arrays. (single-array storage may be more efficient on some implementations; see glInterleavedArrays.) iykyk β¨
when a color array is specified, size, type, stride, and ptr are saved as client-side state.
to enable and disable the color array, call glEnableClientState and glDisableClientState with the argument GL_COLOR_ARRAY. if it's enabled, the color array is used when glDrawArrays, glDrawElements, glDrawRangeElements, or glArrayElement is called. that's the moment it actually does something, bestie π
π NOTES π
glColorPointeris available only if the GL version is1.1or greater. no 1.0 girlies allowed, sorry π- the color array is initially disabled and isn't accessed when
glArrayElement,glDrawArrays,glDrawRangeElements, orglDrawElementsis called. - execution of
glColorPointeris not allowed between the execution ofglBeginand the corresponding execution ofglEndβ but an error may or may not be generated. and if no error is generated? the operation is undefined. so like. don't. π glColorPointeris typically implemented on the client side.- color array parameters are client-side state, so they are NOT saved or restored by
glPushAttribandglPopAttrib. useglPushClientAttribandglPopClientAttribinstead. this one trips people up fr fr π
π ERRORS π
GL_INVALID_VALUEis generated ifsizeis not3or4.GL_INVALID_ENUMis generated iftypeis not an accepted value.GL_INVALID_VALUEis generated ifstrideis negative.
π ASSOCIATED GETS π
glIsEnabledwith argumentGL_COLOR_ARRAYglGetwith argumentGL_COLOR_ARRAY_SIZEglGetwith argumentGL_COLOR_ARRAY_TYPEglGetwith argumentGL_COLOR_ARRAY_STRIDEglGetPointervwith argumentGL_COLOR_ARRAY_POINTER
π§ SEE ALSO π§
glArrayElement(3G)glDrawArrays(3G)glDrawElements(3G)glEdgeFlagPointer(3G)glEnable(3G)glGetPointerv(3G)glIndexPointer(3G)glInterleavedArrays(3G)glNormalPointer(3G)glPopClientAttrib(3G)glPushClientAttrib(3G)glTexCoordPointer(3G)glVertexPointer(3G)
quick vibe check:glColorPointeronly exists if your GL version is1.1or higher, and it's straight up undefined behavior if you sneak it in betweenglBeginandglEnd. the manpage is being so real about this one, so be real back π«Ά
okay that's the whole page, no cap, every last flag and constant accounted for π and for the sign-off: this one lives in the GLCOLORPOINTER(3G) section of the manual β and yeah, the source and date line is literally just the same GLCOLORPOINTER(3G) tag, no version number, no date, nothing. she's mysterious like that π
β¨ slay, go forth and pointer your colors ππ
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- fedora 43: gl-manpages 1.1-34.20190306.fc43 Β· Apache-2.0 AND HPND AND HPND-sell-variant AND MIT AND OpenPBS-2.3 AND SGI-B-2.0 AND W3C-19980720 AND X11
- fedora 44: gl-manpages 1.1-35.20190306.fc44 Β· Apache-2.0 AND HPND AND HPND-sell-variant AND MIT AND OpenPBS-2.3 AND SGI-B-2.0 AND W3C-19980720 AND X11
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms