GLGETMATERIAL(3G)
β¨ 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_FRONTorGL_BACK, and yes they mean the front material and the back material respectively, periodt.pnameβ which material parameter do you want back. accepted values areGL_AMBIENT,GL_DIFFUSE,GL_SPECULAR,GL_EMISSION,GL_SHININESS, andGL_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βparamsgets 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, so1.0maps to the most positive representable integer value and-1.0maps 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βparamsgets 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 that1.0maps to the most positive representable integer value and-1.0maps 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βparamsgets 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 that1.0maps to the most positive representable integer value and-1.0maps 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βparamsgets 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 that1.0maps to the most positive representable integer value and-1.0maps 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βparamsgets 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 is0.GL_COLOR_INDEXESβparamsgets 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_ENUMis generated iffaceorpnameis not an accepted value. (read the parameters section again bestie, we listed them π )GL_INVALID_OPERATIONis generated ifglGetMaterialis executed between the execution ofglBeginand the corresponding execution ofglEnd. so not in the middle of aglBegin/glEndsandwich. 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
- opensuse-leap 16.0: Mesa-libGL-devel 24.1.7-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms