2 * Copyright © 2010 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 * Tests that the three fog modes work with fog enabled using EXT_fog_coord.
29 #include "piglit-util-gl.h"
31 PIGLIT_GL_TEST_CONFIG_BEGIN
33 config
.supports_gl_compat_version
= 10;
35 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
37 PIGLIT_GL_TEST_CONFIG_END
42 GLboolean pass
= GL_TRUE
;
44 float near
= 0.0, far
= 1.0;
45 GLfloat fogcolor
[4] = {1, 1, 1, 1};
48 glFogfv(GL_FOG_COLOR
, fogcolor
);
49 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);
50 glColor4f(0, 0, 0, 0.5);
52 glMatrixMode(GL_PROJECTION
);
54 glOrtho(0, 1, 0, 1, -near
, -far
);
56 for (mode
= 0; mode
< 3; mode
++) {
62 glFogi(GL_FOG_MODE
, GL_LINEAR
);
63 glFogf(GL_FOG_START
, near
);
64 glFogf(GL_FOG_END
, far
);
67 glFogi(GL_FOG_MODE
, GL_EXP
);
68 glFogf(GL_FOG_DENSITY
, 2);
71 glFogi(GL_FOG_MODE
, GL_EXP2
);
72 glFogf(GL_FOG_DENSITY
, 2);
76 for (i
= 0; i
< 5; i
++) {
79 float z
= near
+ (far
- near
) * i
/ 5.0;
82 piglit_draw_rect(x
, y
, w
, h
);
86 for (mode
= 0; mode
< 3; mode
++) {
87 float y
= (mode
+ 0.5) / 3.0 * piglit_height
;
88 for (i
= 0; i
< 5; i
++) {
89 float x
= (i
+ 0.5) / 5.0 * piglit_width
;
90 float z
= near
+ (far
- near
) * i
/ 5.0;
96 f
= (far
- z
) / (far
- near
);
102 f
= expf(-(2.0 * z
) * (2.0 * z
));
115 pass
= pass
& piglit_probe_pixel_rgba(x
, y
, color
);
119 piglit_present_results();
121 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
124 void piglit_init(int argc
, char**argv
)
126 piglit_require_extension("GL_EXT_fog_coord");