GLFOG(3G)
π«οΈβ¨ 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 areGL_FOG_MODE,GL_FOG_DENSITY,GL_FOG_START,GL_FOG_END, andGL_FOG_INDEX.paramβ the value thatpnameis 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 gotGL_FOG_MODE,GL_FOG_DENSITY,GL_FOG_START,GL_FOG_END,GL_FOG_INDEX, andGL_FOG_COLORaccepted. yes, the color one is the whole reason these versions exist. πparamsβ the value (or values, plural, she's an array) to be assigned topname. heads up:GL_FOG_COLORrequires 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βparamsis 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, andGL_EXP2. the equations for those are defined below (scroll down bestie, they're right there). the initial fog mode isGL_EXP.GL_FOG_DENSITYβparamsis a single integer or floating-point value that specifiesdensity, the fog density used in both exponential fog equations. only nonnegative densities are accepted β negative density is a no. the initial fog density is1.GL_FOG_STARTβparamsis a single integer or floating-point value that specifiesstart, the near distance used in the linear fog equation. the initial near distance is0.GL_FOG_ENDβparamsis a single integer or floating-point value that specifiesend, the far distance used in the linear fog equation. the initial far distance is1.GL_FOG_INDEXβparamsis a single integer or floating-point value that specifiesif, the fog color index. the initial fog index is0.GL_FOG_COLORβparamscontains four integer or floating-point values that specifyCf, the fog color. integer values get mapped linearly such that the most positive representable value maps to1.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_ENUMis generated ifpnameis not an accepted value, or ifpnameisGL_FOG_MODEandparamsis not an accepted value. pick from the list, babe, that's the whole assignment. πGL_INVALID_VALUEis generated ifpnameisGL_FOG_DENSITY, andparamsis negative. no negative density. i said what i said. π«GL_INVALID_OPERATIONis generated ifglFogis executed between the execution ofglBeginand the corresponding execution ofglEnd. 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:
glIsEnabledwith argumentGL_FOGglGetwith argumentGL_FOG_COLORglGetwith argumentGL_FOG_INDEXglGetwith argumentGL_FOG_DENSITYglGetwith argumentGL_FOG_STARTglGetwith argumentGL_FOG_ENDglGetwith argumentGL_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
- 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