GLGETLIGHT(3G)

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

πŸ’‘ 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 like GL_LIGHTi where 0 ≀ i < GL_MAX_LIGHTS 🌈
  • pname β€” which parameter of that light you want. the accepted symbolic names are GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_POSITION, GL_SPOT_DIRECTION, GL_SPOT_EXPONENT, GL_SPOT_CUTOFF, GL_CONSTANT_ATTENUATION, GL_LINEAR_ATTENUATION, and GL_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 β€” params returns 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 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 😭 (so like, don't come for it). the initial value is (0, 0, 0, 1).
  • GL_DIFFUSE β€” params returns 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 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 for GL_LIGHT0 is (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 β€” params returns 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 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 for GL_LIGHT0 is (1, 1, 1, 1); for other lights, the initial value is (0, 0, 0, 0).
  • GL_POSITION β€” params returns 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 using glLight, unless the modelview matrix was identity at the time glLight was called. the initial value is (0, 0, 1, 0). yes this is the sneaky one, iykyk πŸ™ˆ
  • GL_SPOT_DIRECTION β€” params returns 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 using glLight, unless the modelview matrix was identity at the time glLight was 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 β€” params returns 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 is 0.
  • GL_SPOT_CUTOFF β€” params returns 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 is 180.
  • GL_CONSTANT_ATTENUATION β€” params returns 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 is 1.
  • GL_LINEAR_ATTENUATION β€” params returns 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 is 0.
  • GL_QUADRATIC_ATTENUATION β€” params returns 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 is 0.

πŸ¦‹ 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_ENUM is generated if light or pname is not an accepted value. (you made up a name bestie, it's not real)
  • GL_INVALID_OPERATION is generated if glGetLight is executed between the execution of glBegin and the corresponding execution of glEnd. so like, do NOT try this inside a glBegin/glEnd block, 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 the GLGETLIGHT(3G) page, straight out of the 3G manual section β€” go forth and query your lights, bestie, and remember: params only changes when there's no error. periodt. πŸ’…βœ¨πŸŒΈ
πŸ“¦ where this page comes from