1GLFOG(3G) GLFOG(3G)
2
3
4
6 glFogf, glFogi, glFogfv, glFogiv - specify fog parameters
7
8
10 void glFogf( GLenum pname,
11 GLfloat param )
12 void glFogi( GLenum pname,
13 GLint param )
14
15
17 pname Specifies a single-valued fog parameter. GL_FOG_MODE,
18 GL_FOG_DENSITY, GL_FOG_START, GL_FOG_END, and GL_FOG_INDEX are
19 accepted.
20
21 param Specifies the value that pname will be set to.
22
24 void glFogfv( GLenum pname,
25 const GLfloat *params )
26 void glFogiv( GLenum pname,
27 const GLint *params )
28
29
31 pname Specifies a fog parameter. GL_FOG_MODE, GL_FOG_DENSITY,
32 GL_FOG_START, GL_FOG_END, GL_FOG_INDEX, and GL_FOG_COLOR are
33 accepted.
34
35 params Specifies the value or values to be assigned to pname.
36 GL_FOG_COLOR requires an array of four values. All other param‐
37 eters accept an array containing only a single value.
38
40 Fog is initially disabled. While enabled, fog affects rasterized geom‐
41 etry, bitmaps, and pixel blocks, but not buffer clear operations. To
42 enable and disable fog, call glEnable and glDisable with argument
43 GL_FOG.
44
45 glFog assigns the value or values in params to the fog parameter speci‐
46 fied by pname. The following values are accepted for pname:
47
48 GL_FOG_MODE params is a single integer or floating-point value
49 that specifies the equation to be used to compute
50 the fog blend factor, f. Three symbolic constants
51 are accepted: GL_LINEAR, GL_EXP, and GL_EXP2. The
52 equations corresponding to these symbolic constants
53 are defined below. The initial fog mode is GL_EXP.
54
55 GL_FOG_DENSITY params is a single integer or floating-point value
56 that specifies density, the fog density used in
57 both exponential fog equations. Only nonnegative
58 densities are accepted. The initial fog density is
59 1.
60
61 GL_FOG_START params is a single integer or floating-point value
62 that specifies start, the near distance used in the
63 linear fog equation. The initial near distance is
64 0.
65
66 GL_FOG_END params is a single integer or floating-point value
67 that specifies end, the far distance used in the
68 linear fog equation. The initial far distance is
69 1.
70
71 GL_FOG_INDEX params is a single integer or floating-point value
72 that specifies if, the fog color index. The ini‐
73 tial fog index is 0.
74
75 GL_FOG_COLOR params contains four integer or floating-point val‐
76 ues that specify Cf, the fog color. Integer values
77 are mapped linearly such that the most positive
78 representable value maps to 1.0, and the most nega‐
79 tive representable value maps to -1.0. Floating-
80 point values are mapped directly. After conver‐
81 sion, all color components are clamped to the range
82 [0,1]. The initial fog color is (0, 0, 0, 0).
83
84 Fog blends a fog color with each rasterized pixel fragment's posttex‐
85 turing color using a blending factor f. Factor f is computed in one of
86 three ways, depending on the fog mode. Let z be the distance in eye
87 coordinates from the origin to the fragment being fogged. The equation
88 for GL_LINEAR fog is
89
90 f=e_n_ed_n−_ds_−t_za_r_t_
91
92
93The equation for GL_EXP fog is
94
95 f=e−(density⋅z)
96
97
98The equation for GL_EXP2 fog is
99
100 f=e−(density⋅z)2
101
102
103Regardless of the fog mode, f is clamped to the range [0, 1] after it is com‐
104puted. Then, if the GL is in RGBA color mode, the fragment's red, green, and
105blue colors, represented by Cr, are replaced by
106
107 Cr′=fCr+(1−f)Cf
108
109
110Fog does not affect a fragment's alpha component.
111
112In color index mode, the fragment's color index ir is replaced by
113
114 ir′=ir+(1−f)if
115
117 GL_INVALID_ENUM is generated if pname is not an accepted value, or if
118 pname is GL_FOG_MODE and params is not an accepted value.
119
120 GL_INVALID_VALUE is generated if pname is GL_FOG_DENSITY, and params is
121 negative.
122
123 GL_INVALID_OPERATION is generated if glFog is executed between the exe‐
124 cution of glBegin and the corresponding execution of glEnd.
125
127 glIsEnabled with argument GL_FOG
128 glGet with argument GL_FOG_COLOR
129 glGet with argument GL_FOG_INDEX
130 glGet with argument GL_FOG_DENSITY
131 glGet with argument GL_FOG_START
132 glGet with argument GL_FOG_END
133 glGet with argument GL_FOG_MODE
134
136 glEnable(3G)
137
138
139
140 GLFOG(3G)