GLCOLORMATERIAL(3G)

πŸ“¦ version 1.1, in centos-stream 9, fedora 43, fedora 44

πŸ’… 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 are GL_FRONT, GL_BACK, and GL_FRONT_AND_BACK. The initial value is GL_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 are GL_EMISSION, GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, and GL_AMBIENT_AND_DIFFUSE. The initial value is GL_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. ✨

Call glColorMaterial before enabling GL_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_ENUM gets generated if face or mode isn't one of the accepted values. Pick from the list, babe. πŸ’…
  • GL_INVALID_OPERATION gets generated if glColorMaterial is executed between the execution of glBegin and the corresponding execution of glEnd. Don't do that. That's the forbidden window. 🚫

🌈 ASSOCIATED GETS 🌈

  • glIsEnabled with argument GL_COLOR_MATERIAL
  • glGet with argument GL_COLOR_MATERIAL_PARAMETER
  • glGet with argument GL_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