GLCOLORMATERIAL(3G)
π GLCOLORMATERIAL(3G) β bestie, your materials are about to be so tracked β¨
Okay so this is the manual page for glColorMaterial(3G), and it's genuinely one of those little OpenGL functions that does one thing and does it beautifully. Sit down, grab a boba, we're doing material colors. π§
β¨ NAME β¨
glColorMaterial β make a material color follow the current color around like a loyal bestie. π«Ά
πΈ C SPECIFICATION πΈ
void glColorMaterial( GLenum face,
GLenum mode )
π PARAMETERS π
faceβ tells us who is tracking the current color: the front material, the back material, or both of them at once. The accepted values areGL_FRONT,GL_BACK, andGL_FRONT_AND_BACK. The initial value isGL_FRONT_AND_BACK, so by default literally everyone is invited to the party. πmodeβ picks which material parameter(s) get to follow the current color. Accepted values areGL_EMISSION,GL_AMBIENT,GL_DIFFUSE,GL_SPECULAR, andGL_AMBIENT_AND_DIFFUSE. The initial value isGL_AMBIENT_AND_DIFFUSE. π
π¦ DESCRIPTION π¦
So glColorMaterial says which material parameters track the current color. When GL_COLOR_MATERIAL is enabled, the parameter(s) you named in mode, on the material(s) you named in face, track the current color at all times. Like, always. No days off. π
To turn GL_COLOR_MATERIAL on and off, call glEnable and glDisable with the argument GL_COLOR_MATERIAL. And heads up: GL_COLOR_MATERIAL is initially disabled, so you do gotta enable it yourself. π
π NOTES π
glColorMaterial is the moment because it lets you change a subset of material parameters for every vertex using only glColor, no glMaterial call required. And if that subset is all you need per vertex? Then calling glColorMaterial is genuinely preferable to calling glMaterial. Slay. β¨
CallglColorMaterialbefore enablingGL_COLOR_MATERIAL. Order matters, bestie, do not play with this one.
Calling glDrawElements, glDrawArrays, or glDrawRangeElements may leave the current color indeterminate if the color array is enabled. And if glColorMaterial is enabled while the current color is indeterminate, then the lighting material state specified by face and mode is also indeterminate. Yes, the chaos is contagious. π
If the GL version is 1.1 or greater, and GL_COLOR_MATERIAL is enabled, evaluated color values affect the results of the lighting equation as if the current color were being modified β but no change is made to the tracking lighting parameter of the current color. Sneaky little detail, iykyk. π§
π₯ ERRORS π₯
GL_INVALID_ENUMgets generated iffaceormodeisn't one of the accepted values. Pick from the list, babe. πGL_INVALID_OPERATIONgets generated ifglColorMaterialis executed between the execution ofglBeginand the corresponding execution ofglEnd. Don't do that. That's the forbidden window. π«
π ASSOCIATED GETS π
glIsEnabledwith argumentGL_COLOR_MATERIALglGetwith argumentGL_COLOR_MATERIAL_PARAMETERglGetwith argumentGL_COLOR_MATERIAL_FACE
β SEE ALSO β
glColor(3G), glColorPointer(3G), glDrawArrays(3G), glDrawElements(3G), glDrawRangeElements(3G), glEnable(3G), glLight(3G), glLightModel(3G), glMaterial(3G)
And that's the whole page, bestie β this was GLCOLORMATERIAL(3G) from the GLCOLORMATERIAL(3G) manual, and yes, the footer is literally just the name again, we love a consistent queen. πβ¨ Go forth and track some colors. Periodt. π
π¦ 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