These functions specify fog parameters.
void glFogf(
GLenum pname,
GLfloat param
);
void glFogi(
GLenum pname,
GLint param
);
void glFogfv(
GLenum pname,
const GLfloat * params
);
void glFogiv(
GLenum pname,
const GLint * params
);
In glFogfv and glFogiv, specifies a fog parameter.
The glFogf, glFogi, glFogfv, and glFogiv functions accept the following values:
The glFogfv and glFogiv functions also accept GL_FOG_COLOR:
You enable and disable fog with glEnable and glDisable, using the argument GL_FOG. While enabled, fog affects rasterized geometry, bitmaps, and pixel blocks, but not buffer-clear operations.
The glFog function assigns the value or values in params to the fog parameter specified by pname.
Fog blends a fog color with each rasterized pixel fragment's posttexturing color using a blending factor f. Factor f is 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:
The equation for GL_EXP fog is:
The equation for GL_EXP2 fog is:
Regardless of the fog mode, f is clamped to the range [0,1] after it is computed. Then, if OpenGL is in RGBA color mode, the fragment's color C (r) is replaced by
In color-index mode, the fragment's color index i (r) is replaced by
The following functions retrieve information related to the glFog functions:
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
glIsEnabled with argument GL_FOG
The following are the error codes generated and their conditions.
Error Code | Condition |
---|---|
GL_INVALID_ENUM | pname was not an accepted value. |
GL_INVALID_OPERATION | glFinish was called between a call to glBegin and the corresponding call to glEnd. |
Windows NT: Use version 3.5 and later.
Windows: Use Windows 95 and later.
Windows CE: Unsupported.
Header: Declared in gl.h.
Import Library: Link with opengl32.lib.
glBegin, glDisable, glEnable, glEnd, glGet, glIsEnabled