GLFOG(3G)

πŸ“¦ version 24.3.3, in opensuse-leap 16.0

🌫️✨ GLFOG β€” bestie edition ✨🌫️

okay so real talk, this is the 3G man page for glFogf, glFogi, glFogfv, glFogiv β€” the little squad of functions whose whole job is specify fog parameters. yes. actual fog. the atmospheric haze that makes your 3D scene look like a moody morning in a forest instead of a sad untextured cube. πŸ¦‹


πŸ’– NAME πŸ’–

glFogf, glFogi, glFogfv, glFogiv β€” specify fog parameters 🌫️

like. that's it. that's the name section. four functions, one vibe, all the fog.


🌸 C SPECIFICATION 🌸

void glFogf( GLenum pname,
             GLfloat param )
void glFogi( GLenum pname,
             GLint param )

πŸŽ€ PARAMETERS πŸŽ€

  • pname β€” this one's the single-valued fog parameter, bestie. the accepted girlies here are GL_FOG_MODE, GL_FOG_DENSITY, GL_FOG_START, GL_FOG_END, and GL_FOG_INDEX.
  • param β€” the value that pname is gonna get set to. simple as. πŸ’…

πŸ¦‹ C SPECIFICATION (the pointer girlies) πŸ¦‹

void glFogfv( GLenum pname,
              const GLfloat *params )
void glFogiv( GLenum pname,
              const GLint *params )

🌈 PARAMETERS (again, but now with arrays) 🌈

  • pname β€” a fog parameter. this time around you've got GL_FOG_MODE, GL_FOG_DENSITY, GL_FOG_START, GL_FOG_END, GL_FOG_INDEX, and GL_FOG_COLOR accepted. yes, the color one is the whole reason these versions exist. πŸ‘‘
  • params β€” the value (or values, plural, she's an array) to be assigned to pname. heads up: GL_FOG_COLOR requires an array of four values. every other parameter just takes an array with a single value in it. that's the whole deal. πŸ“

πŸ‘‘ DESCRIPTION πŸ‘‘

Fog is initially disabled. like, off. asleep. no fog. 😴

But while it is enabled, fog affects rasterized geometry, bitmaps, and pixel blocks β€” but not buffer clear operations, okay? clear ops are immune. to enable and disable fog, you call glEnable and glDisable with the argument GL_FOG. that's the switch. flip it. 🫢

glFog assigns the value or values in params to the fog parameter specified by pname. and these are the pname values it accepts:

  • GL_FOG_MODE β€” params is a single integer or floating-point value that specifies the equation used to compute the fog blend factor, f. three symbolic constants get accepted here: GL_LINEAR, GL_EXP, and GL_EXP2. the equations for those are defined below (scroll down bestie, they're right there). the initial fog mode is GL_EXP.
  • GL_FOG_DENSITY β€” params is a single integer or floating-point value that specifies density, the fog density used in both exponential fog equations. only nonnegative densities are accepted β€” negative density is a no. the initial fog density is 1.
  • GL_FOG_START β€” params is a single integer or floating-point value that specifies start, the near distance used in the linear fog equation. the initial near distance is 0.
  • GL_FOG_END β€” params is a single integer or floating-point value that specifies end, the far distance used in the linear fog equation. the initial far distance is 1.
  • GL_FOG_INDEX β€” params is a single integer or floating-point value that specifies if, the fog color index. the initial fog index is 0.
  • GL_FOG_COLOR β€” params contains four integer or floating-point values that specify Cf, the fog color. integer values get mapped linearly such that the most positive representable value maps to 1.0, and the most negative representable value maps to -1.0. floating-point values are mapped directly. after conversion, all color components are clamped to the range [0,1]. the initial fog color is (0, 0, 0, 0).

Fog blends a fog color with each rasterized pixel fragment's posttexturing color using a blending factor f. πŸ’«

Factor f gets computed in one of three ways, depending on the fog mode. Let z be the distance in eye coordinates from the origin to the fragment being fogged. 🌫️

The equation for GL_LINEAR fog is:

                                     f=_________
ok so not to be dramatic but that's literally what the page shows for the linear equation β€” the source got a lil mangled in the printing and I'm not about to invent math that isn't there. what you see is what's on the page, bestie. πŸ™ˆ

The equation for GL_EXP fog is:

                                   f=eβˆ’(densityβ‹…z)

The equation for GL_EXP2 fog is:

                                   f=eβˆ’(densityβ‹…z)2

Regardless of the fog mode, f is clamped to the range [0, 1] after it is computed. ✨

Then, if the GL is in RGBA color mode, the fragment's red, green, and blue colors, represented by Cr, are replaced by:

                                   Crβ€²=fCr+(1βˆ’f)Cf
and no, fog does not affect a fragment's alpha component. alpha stays unbothered. untouched. minding her own business. πŸ’…

In color index mode, the fragment's color index ir is replaced by:

                                    irβ€²=ir+(1βˆ’f)if

πŸ’€ ERRORS πŸ’€

  • GL_INVALID_ENUM is generated if pname is not an accepted value, or if pname is GL_FOG_MODE and params is not an accepted value. pick from the list, babe, that's the whole assignment. πŸ“‹
  • GL_INVALID_VALUE is generated if pname is GL_FOG_DENSITY, and params is negative. no negative density. i said what i said. 🚫
  • GL_INVALID_OPERATION is generated if glFog is executed between the execution of glBegin and the corresponding execution of glEnd. so like… do NOT do that. that's a between-the-brackets crime. 😭

πŸ” ASSOCIATED GETS πŸ”

the little getters that keep tabs on this whole situation:

  • glIsEnabled with argument GL_FOG
  • glGet with argument GL_FOG_COLOR
  • glGet with argument GL_FOG_INDEX
  • glGet with argument GL_FOG_DENSITY
  • glGet with argument GL_FOG_START
  • glGet with argument GL_FOG_END
  • glGet with argument GL_FOG_MODE

🌟 SEE ALSO 🌟

  • glEnable(3G)

and that's the page!! πŸŽ€ the footer just says GLFOG(3G) β€” same as the header, no extra version or date dressing on this one, just the name and the section number being cute and consistent at the very bottom. slay. βœ¨πŸ’–

πŸ“¦ where this page comes from