GLGETMATERIAL(3G)

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

✨ GLGETMATERIAL β€” return material parameters ✨

okay bestie, welcome to the 3G OpenGL manual page πŸ’… this one's about glGetMaterialfv and glGetMaterialiv, which are literally the "hey what's my material looking like rn" functions. no cap.


🌸 NAME 🌸

glGetMaterialfv, glGetMaterialiv β€” return material parameters πŸŽ€


πŸ¦‹ C SPECIFICATION πŸ¦‹

void glGetMaterialfv( GLenum face,
                      GLenum pname,
                      GLfloat *params )
void glGetMaterialiv( GLenum face,
                      GLenum pname,
                      GLint *params )

πŸ’– PARAMETERS πŸ’–

  • face β€” which of the two materials are we even asking about?? GL_FRONT or GL_BACK, and yes they mean the front material and the back material respectively, periodt.
  • pname β€” which material parameter do you want back. accepted values are GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_EMISSION, GL_SHININESS, and GL_COLOR_INDEXES.
  • params β€” where the requested data gets dropped off. it's the output spot 🫢

πŸ‘‘ DESCRIPTION πŸ‘‘

glGetMaterial hands you back, in params, the value (or values!!) of parameter pname for material face. there are six parameters defined and we're going through all of them, no skipping, that's the vibe:

  • GL_AMBIENT β€” params gets four integer or floating-point values, and they represent the ambient reflectance of the material. when you ask for integers, they're linearly mapped from the internal floating-point representation, so 1.0 maps to the most positive representable integer value and -1.0 maps to the most negative representable integer value. ⚠️ and if the internal value is outside the range [-1, 1], the corresponding integer return value is undefined β€” like, genuinely undefined, not "undefined but probably fine". the initial value is (0.2, 0.2, 0.2, 1.0)
  • GL_DIFFUSE β€” params gets four integer or floating-point values representing the diffuse reflectance of the material. integer values, when requested, are linearly mapped from the internal floating-point representation such that 1.0 maps to the most positive representable integer value and -1.0 maps to the most negative representable integer value. if the internal value is outside the range [-1, 1], the corresponding integer return value is undefined 😭 the initial value is (0.8, 0.8, 0.8, 1.0).
  • GL_SPECULAR β€” params gets four integer or floating-point values representing the specular reflectance of the material. integer values, when requested, are linearly mapped from the internal floating-point representation such that 1.0 maps to the most positive representable integer value and -1.0 maps to the most negative representable integer value. if the internal value is outside the range [-1, 1], the corresponding integer return value is undefined πŸ™ˆ the initial value is (0, 0, 0, 1).
  • GL_EMISSION β€” params gets four integer or floating-point values representing the emitted light intensity of the material. integer values, when requested, are linearly mapped from the internal floating-point representation such that 1.0 maps to the most positive representable integer value and -1.0 maps to the most negative representable integer value. if the internal value is outside the range [-1, 1.0], the corresponding integer return value is undefined πŸ’€ the initial value is (0, 0, 0, 1).
  • GL_SHININESS β€” params gets one integer or floating-point value, representing the specular exponent of the material. integer values, when requested, are computed by rounding the internal floating-point value to the nearest integer value. the initial value is 0.
  • GL_COLOR_INDEXES β€” params gets three integer or floating-point values representing the ambient, diffuse, and specular indices of the material. these indices are used only for color index lighting (meanwhile all the other parameters are used only for RGBA lighting β€” different lanes, iykyk). integer values, when requested, are computed by rounding the internal floating-point values to the nearest integer values.

🧚 NOTES 🧚

if an error gets generated, no change is made to the contents of params. so like, nothing sneaky happens in there. 🀝


πŸ”₯ ERRORS πŸ”₯

  • GL_INVALID_ENUM is generated if face or pname is not an accepted value. (read the parameters section again bestie, we listed them πŸ’…)
  • GL_INVALID_OPERATION is generated if glGetMaterial is executed between the execution of glBegin and the corresponding execution of glEnd. so not in the middle of a glBegin/glEnd sandwich. absolutely not. that's the one place it can't go 🚫

🌈 SEE ALSO 🌈

glMaterial(3G)


okay that's the whole page!! go forth and query your materials responsibly, you icon πŸ‘‘πŸ’–

this was GLGETMATERIAL(3G) from the 3G OpenGL manual, and yeah the footer says the same thing because it's the same page, slay. bye bestie!! πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from