NAME

glFogf, glFogi, glFogfv, glFogiv - specify fog parameters

C SPECIFICATION

void ggllFFooggff( GLenum _p_n_a_m_e,
             GLfloat _p_a_r_a_m )
void ggllFFooggii( GLenum _p_n_a_m_e,
             GLint _p_a_r_a_m )

delim $$

PARAMETERS

_p_n_a_m_e
Specifies a single-valued fog parameter. GGLL__FFOOGG__MMOODDEE, GGLL__FFOOGG__DDEENNSSIITTYY, GGLL__FFOOGG__SSTTAARRTT, GGLL__FFOOGG__EENNDD, and GGLL__FFOOGG__IINNDDEEXX are accepted.
_p_a_r_a_m
Specifies the value that _p_n_a_m_e will be set to.

C SPECIFICATION

void ggllFFooggffvv( GLenum _p_n_a_m_e,
              const GLfloat _*_p_a_r_a_m_s )
void ggllFFooggiivv( GLenum _p_n_a_m_e,
              const GLint _*_p_a_r_a_m_s )

PARAMETERS

_p_n_a_m_e
Specifies a fog parameter. GGLL__FFOOGG__MMOODDEE, GGLL__FFOOGG__DDEENNSSIITTYY, GGLL__FFOOGG__SSTTAARRTT, GGLL__FFOOGG__EENNDD, GGLL__FFOOGG__IINNDDEEXX, and GGLL__FFOOGG__CCOOLLOORR are accepted.
_p_a_r_a_m_s
Specifies the value or values to be assigned to _p_n_a_m_e. GGLL__FFOOGG__CCOOLLOORR requires an array of four values. All other parameters accept an array containing only a single value.

DESCRIPTION

Fog is initially disabled. While enabled, fog affects rasterized geometry, bitmaps, and pixel blocks, but not buffer clear operations. To enable and disable fog, call ggllEEnnaabbllee and ggllDDiissaabbllee with argument GGLL__FFOOGG.

ggllFFoogg assigns the value or values in _p_a_r_a_m_s to the fog parameter specified by _p_n_a_m_e. The following values are accepted for _p_n_a_m_e:

GGLL__FFOOGG__MMOODDEE
_p_a_r_a_m_s is a single integer or floating-point value that specifies the equation to be used to compute the fog blend factor, $f$. Three symbolic constants are accepted: GGLL__LLIINNEEAARR, GGLL__EEXXPP, and GGLL__EEXXPP22. The equations corresponding to these symbolic constants are defined below. The initial fog mode is GGLL__EEXXPP.
GGLL__FFOOGG__DDEENNSSIITTYY
_p_a_r_a_m_s 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. The initial fog density is 1.
GGLL__FFOOGG__SSTTAARRTT
_p_a_r_a_m_s 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.
GGLL__FFOOGG__EENNDD
_p_a_r_a_m_s 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.
GGLL__FFOOGG__IINNDDEEXX
_p_a_r_a_m_s is a single integer or floating-point value that specifies $i sub f$, the fog color index. The initial fog index is 0.
GGLL__FFOOGG__CCOOLLOORR
_p_a_r_a_m_s contains four integer or floating-point values that specify $C sub f$, the fog color. Integer values are 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$ 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 GGLL__LLIINNEEAARR fog is

f ~=~ {end ~-~ z} over {end ~-~ start}

The equation for GGLL__EEXXPP fog is

f ~=~ e sup {-^(density ~cdot~ z)}

The equation for GGLL__EEXXPP22 fog is

f ~=~ e sup {-^(density ~cdot~ z)} sup 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 $C sub r$, are replaced by

{C sub r} sup prime ~=~ f^C sub r ~+~ (1 - f)^C sub f



Fog does not affect a fragment's alpha component.

In color index mode, the fragment's color index $i sub r$ is replaced by

{i sub r} sup prime ~=~ i sub r ~+~ (1 - f)^i sub f

ERRORS

GGLL__IINNVVAALLIIDD__EENNUUMM is generated if _p_n_a_m_e is not an accepted value, or if _p_n_a_m_e is GGLL__FFOOGG__MMOODDEE and _p_a_r_a_m_s is not an accepted value.

GGLL__IINNVVAALLIIDD__VVAALLUUEE is generated if _p_n_a_m_e is GGLL__FFOOGG__DDEENNSSIITTYY, and _p_a_r_a_m_s is negative.

GGLL__IINNVVAALLIIDD__OOPPEERRAATTIIOONN is generated if ggllFFoogg is executed between the execution of ggllBBeeggiinn and the corresponding execution of ggllEEnndd.

ASSOCIATED GETS

ggllIIssEEnnaabblleedd with argument GGLL__FFOOGG
ggllGGeett with argument GGLL__FFOOGG__CCOOLLOORR
ggllGGeett with argument GGLL__FFOOGG__IINNDDEEXX
ggllGGeett with argument GGLL__FFOOGG__DDEENNSSIITTYY
ggllGGeett with argument GGLL__FFOOGG__SSTTAARRTT
ggllGGeett with argument GGLL__FFOOGG__EENNDD
ggllGGeett with argument GGLL__FFOOGG__MMOODDEE

SEE ALSO

ggllEEnnaabbllee((33GG))