1GLFOG(3G)                        OpenGL Manual                       GLFOG(3G)
2
3
4

NAME

6       glFog - specify fog parameters
7

C SPECIFICATION

9       void glFogf(GLenum pname, GLfloat param);
10
11       void glFogi(GLenum pname, GLint param);
12

PARAMETERS

14       pname
15           Specifies a single-valued fog parameter.  GL_FOG_MODE,
16           GL_FOG_DENSITY, GL_FOG_START, GL_FOG_END, GL_FOG_INDEX, and
17           GL_FOG_COORD_SRC are accepted.
18
19       param
20           Specifies the value that pname will be set to.
21

C SPECIFICATION

23       void glFogfv(GLenum pname, const GLfloat * params);
24
25       void glFogiv(GLenum pname, const GLint * params);
26

PARAMETERS

28       pname
29           Specifies a fog parameter.  GL_FOG_MODE, GL_FOG_DENSITY,
30           GL_FOG_START, GL_FOG_END, GL_FOG_INDEX, GL_FOG_COLOR, and
31           GL_FOG_COORD_SRC are accepted.
32
33       params
34           Specifies the value or values to be assigned to pname.
35           GL_FOG_COLOR requires an array of four values. All other parameters
36           accept an array containing only a single value.
37

DESCRIPTION

39       Fog is initially disabled. While enabled, fog affects rasterized
40       geometry, bitmaps, and pixel blocks, but not buffer clear operations.
41       To enable and disable fog, call glEnable() and glDisable() with
42       argument GL_FOG.
43
44       glFog assigns the value or values in params to the fog parameter
45       specified by pname. The following values are accepted for pname:
46
47       GL_FOG_MODE
48           params is a single integer or floating-point value that specifies
49           the equation to be used to compute the fog blend factor, f. Three
50           symbolic constants are accepted: GL_LINEAR, GL_EXP, and GL_EXP2.
51           The equations corresponding to these symbolic constants are defined
52           below. The initial fog mode is GL_EXP.
53
54       GL_FOG_DENSITY
55           params is a single integer or floating-point value that specifies
56           density, the fog density used in both exponential fog equations.
57           Only nonnegative densities are accepted. The initial fog density is
58           1.
59
60       GL_FOG_START
61           params is a single integer or floating-point value that specifies
62           start, the near distance used in the linear fog equation. The
63           initial near distance is 0.
64
65       GL_FOG_END
66           params is a single integer or floating-point value that specifies
67           end, the far distance used in the linear fog equation. The initial
68           far distance is 1.
69
70       GL_FOG_INDEX
71           params is a single integer or floating-point value that specifies i
72           f, the fog color index. The initial fog index is 0.
73
74       GL_FOG_COLOR
75           params contains four integer or floating-point values that specify
76           C f, the fog color. Integer values are mapped linearly such that
77           the most positive representable value maps to 1.0, and the most
78           negative representable value maps to -1.0. Floating-point values
79           are mapped directly. After conversion, all color components are
80           clamped to the range 0 1. The initial fog color is (0, 0, 0, 0).
81
82       GL_FOG_COORD_SRC
83           params contains either of the following symbolic constants:
84           GL_FOG_COORD or GL_FRAGMENT_DEPTH.  GL_FOG_COORD specifies that the
85           current fog coordinate should be used as distance value in the fog
86           color computation.  GL_FRAGMENT_DEPTH specifies that the current
87           fragment depth should be used as distance value in the fog
88           computation.
89
90       Fog blends a fog color with each rasterized pixel fragment's
91       post-texturing color using a blending factor f. Factor f is computed in
92       one of three ways, depending on the fog mode. Let c be either the
93       distance in eye coordinate from the origin (in the case that the
94       GL_FOG_COORD_SRC is GL_FRAGMENT_DEPTH) or the current fog coordinate
95       (in the case that GL_FOG_COORD_SRC is GL_FOG_COORD). The equation for
96       GL_LINEAR fog is f = end - c end - start
97
98       The equation for GL_EXP fog is f = e - density ⋅ c
99
100       The equation for GL_EXP2 fog is f = e - density ⋅ c 2
101
102       Regardless of the fog mode, f is clamped to the range 0 1 after it is
103       computed. Then, if the GL is in RGBA color mode, the fragment's red,
104       green, and blue colors, represented by C r, are replaced by
105
106       C r ″ = f × C r + 1 - f × C f
107
108       Fog does not affect a fragment's alpha component.
109
110       In color index mode, the fragment's color index i r is replaced by
111
112       i r ″ = i r + 1 - f × i f
113

NOTES

115       GL_FOG_COORD_SRC is available only if the GL version is 1.4 or greater.
116

ERRORS

118       GL_INVALID_ENUM is generated if pname is not an accepted value, or if
119       pname is GL_FOG_MODE and params is not an accepted value.
120
121       GL_INVALID_VALUE is generated if pname is GL_FOG_DENSITY and params is
122       negative.
123
124       GL_INVALID_OPERATION is generated if glFog is executed between the
125       execution of glBegin() and the corresponding execution of glEnd().
126

ASSOCIATED GETS

128       glIsEnabled() with argument GL_FOG
129
130       glGet() with argument GL_FOG_COLOR
131
132       glGet() with argument GL_FOG_INDEX
133
134       glGet() with argument GL_FOG_DENSITY
135
136       glGet() with argument GL_FOG_START
137
138       glGet() with argument GL_FOG_END
139
140       glGet() with argument GL_FOG_MODE
141

SEE ALSO

143       glEnable()
144
146       Copyright © 1991-2006 Silicon Graphics, Inc. This document is licensed
147       under the SGI Free Software B License. For details, see
148       http://oss.sgi.com/projects/FreeB/.
149

AUTHORS

151       opengl.org
152
153
154
155opengl.org                        07/13/2018                         GLFOG(3G)
Impressum