2 * Copyright © 2008 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
21 * DEALINGS IN THE SOFTWARE.
26 * Test passing fog coordinates into a fragment program.
28 * \author Ian Romanick <ian.d.romanick@intel.com>
31 #include "piglit-util-gl.h"
33 static GLint prog
= 0;
35 static const char* const program_text
=
37 "MOV result.color, fragment.fogcoord;\n"
41 PIGLIT_GL_TEST_CONFIG_BEGIN
43 config
.supports_gl_compat_version
= 10;
45 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
47 PIGLIT_GL_TEST_CONFIG_END
49 static PFNGLFOGCOORDFPROC pglFogCoordf
= NULL
;
66 piglit_ortho_projection(2.0, 2.0, GL_FALSE
);
68 glClear(GL_COLOR_BUFFER_BIT
);
102 for (i
= 0; i
< 4; i
++) {
103 float expected_color
[4];
105 expected_color
[0] = probes
[i
].r
;
106 expected_color
[1] = 0.0;
107 expected_color
[2] = 0.0;
108 expected_color
[3] = 1.0;
110 pass
&= piglit_probe_pixel_rgba(probes
[i
].x
* piglit_width
/ 2,
111 probes
[i
].y
* piglit_height
/ 2,
115 piglit_present_results();
117 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
121 piglit_init(int argc
, char **argv
)
123 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
125 glClearColor(0.3, 0.3, 0.3, 0.3);
127 if (piglit_get_gl_version() >= 14) {
128 pglFogCoordf
= glFogCoordf
;
129 } else if (piglit_is_extension_supported("GL_EXT_fog_coord")) {
130 pglFogCoordf
= glFogCoordfEXT
;
132 piglit_report_result(PIGLIT_SKIP
);
135 piglit_require_fragment_program();
136 prog
= piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB
, program_text
);
138 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
139 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, prog
);
141 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);