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 the depth value.
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 zNear
= 0.0, zFar
= 1.0;
45 GLfloat fogcolor
[4] = {1, 1, 1, 1};
48 glFogfv(GL_FOG_COLOR
, fogcolor
);
49 glColor4f(0, 0, 0, 0.5);
51 glMatrixMode(GL_PROJECTION
);
53 glOrtho(0, 1, 0, 1, -zNear
, -zFar
);
55 for (mode
= 0; mode
< 3; mode
++) {
61 glFogi(GL_FOG_MODE
, GL_LINEAR
);
62 glFogf(GL_FOG_START
, zNear
);
63 glFogf(GL_FOG_END
, zFar
);
66 glFogi(GL_FOG_MODE
, GL_EXP
);
67 glFogf(GL_FOG_DENSITY
, 2);
70 glFogi(GL_FOG_MODE
, GL_EXP2
);
71 glFogf(GL_FOG_DENSITY
, 2);
75 for (i
= 0; i
< 5; i
++) {
78 float z
= zNear
+ (zFar
- zNear
) * i
/ 5.0;
80 piglit_draw_rect_z(z
, x
, y
, w
, h
);
84 for (mode
= 0; mode
< 3; mode
++) {
85 float y
= (mode
+ 0.5) / 3.0 * piglit_height
;
86 for (i
= 0; i
< 5; i
++) {
87 float x
= (i
+ 0.5) / 5.0 * piglit_width
;
88 float z
= zNear
+ (zFar
- zNear
) * i
/ 5.0;
94 f
= (zFar
- z
) / (zFar
- zNear
);
100 f
= expf(-(2.0 * z
) * (2.0 * z
));
113 pass
= pass
& piglit_probe_pixel_rgba(x
, y
, color
);
117 piglit_present_results();
119 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
122 void piglit_init(int argc
, char**argv
)