GLGETLIGHT(3G)
π‘ GLGETLIGHT β ok bestie, let's read the vibes of your lights β¨
so this is the GLGETLIGHT page from the 3G manual section, and it's literally all about asking your OpenGL lights "hey, what are your current settings?" π no cap, it's the read-only bestie to glLight's write-everything energy.
β¨ NAME β¨
glGetLightfv, glGetLightiv β return light source parameter values π
πΈ C SPECIFICATION πΈ
void glGetLightfv( GLenum light,
GLenum pname,
GLfloat *params )
void glGetLightiv( GLenum light,
GLenum pname,
GLint *params )
two icons, one job. fv gives you floats, iv gives you ints. pick your fighter π«Ά
π PARAMETERS π
lightβ which light source we're snooping on, bestie. how many lights you actually get depends on the implementation, but at least eight are supported, so you're never light-poor. they're named with symbolic names shaped likeGL_LIGHTiwhere 0 β€ i < GL_MAX_LIGHTS πpnameβ which parameter of that light you want. the accepted symbolic names areGL_AMBIENT,GL_DIFFUSE,GL_SPECULAR,GL_POSITION,GL_SPOT_DIRECTION,GL_SPOT_EXPONENT,GL_SPOT_CUTOFF,GL_CONSTANT_ATTENUATION,GL_LINEAR_ATTENUATION, andGL_QUADRATIC_ATTENUATION. yes that's ten, we counted πparamsβ where the requested data gets dropped. it's the return slot, it's the whole point, it's giving mailbox π¬
π DESCRIPTION π
glGetLight returns in params the value or values of a light source parameter. light names the light and is a symbolic name of the form GL_LIGHTi for 0 β€ i < GL_MAX_LIGHTS, where GL_MAX_LIGHTS is an implementation dependent constant that is greater than or equal to eight. pname specifies one of ten light source parameters, again by symbolic name.
the following parameters are defined:
GL_AMBIENTβparamsreturns four integer or floating-point values representing the ambient intensity of the light source. 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 π (so like, don't come for it). the initial value is(0, 0, 0, 1).GL_DIFFUSEβparamsreturns four integer or floating-point values representing the diffuse intensity of the light source. 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 forGL_LIGHT0is(1, 1, 1, 1); for other lights, the initial value is(0, 0, 0, 0). so light zero is the main character, obvi β¨GL_SPECULARβparamsreturns four integer or floating-point values representing the specular intensity of the light source. 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 forGL_LIGHT0is(1, 1, 1, 1); for other lights, the initial value is(0, 0, 0, 0).GL_POSITIONβparamsreturns four integer or floating-point values representing the position of the light source. integer values, when requested, are computed by rounding the internal floating-point values to the nearest integer value. the returned values are those maintained in eye coordinates. they will not be equal to the values specified usingglLight, unless the modelview matrix was identity at the timeglLightwas called. the initial value is(0, 0, 1, 0). yes this is the sneaky one, iykyk πGL_SPOT_DIRECTIONβparamsreturns three integer or floating-point values representing the direction of the light source. integer values, when requested, are computed by rounding the internal floating-point values to the nearest integer value. the returned values are those maintained in eye coordinates. they will not be equal to the values specified usingglLight, unless the modelview matrix was identity at the timeglLightwas called. although spot direction is normalized before being used in the lighting equation, the returned values are the transformed versions of the specified values prior to normalization. the initial value is(0, 0, -1).GL_SPOT_EXPONENTβparamsreturns a single integer or floating-point value representing the spot exponent of the light. an integer value, when requested, is computed by rounding the internal floating-point representation to the nearest integer. the initial value is0.GL_SPOT_CUTOFFβparamsreturns a single integer or floating-point value representing the spot cutoff angle of the light. an integer value, when requested, is computed by rounding the internal floating-point representation to the nearest integer. the initial value is180.GL_CONSTANT_ATTENUATIONβparamsreturns a single integer or floating-point value representing the constant (not distance-related) attenuation of the light. an integer value, when requested, is computed by rounding the internal floating-point representation to the nearest integer. the initial value is1.GL_LINEAR_ATTENUATIONβparamsreturns a single integer or floating-point value representing the linear attenuation of the light. an integer value, when requested, is computed by rounding the internal floating-point representation to the nearest integer. the initial value is0.GL_QUADRATIC_ATTENUATIONβparamsreturns a single integer or floating-point value representing the quadratic attenuation of the light. an integer value, when requested, is computed by rounding the internal floating-point representation to the nearest integer. the initial value is0.
π¦ NOTES π¦
it is always the case that GL_LIGHTi = GL_LIGHT0 + i. π
if an error is generated, no change is made to the contents of params. so your buffer stays exactly as it was, no half-updates, no drama.
π ERRORS π
GL_INVALID_ENUMis generated iflightorpnameis not an accepted value. (you made up a name bestie, it's not real)GL_INVALID_OPERATIONis generated ifglGetLightis executed between the execution ofglBeginand the corresponding execution ofglEnd. so like, do NOT try this inside aglBegin/glEndblock, that's the forbidden zone π«
π SEE ALSO π
glLight(3G)β the other half of this situationship π
ok that's the whole page, you ate it, congrats π
this was theGLGETLIGHT(3G)page, straight out of the3Gmanual section β go forth and query your lights, bestie, and remember:paramsonly changes when there's no error. periodt. π β¨πΈ
π¦ 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