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.h"
33 static GLint prog
= 0;
35 static const char* const program_text
=
37 "MOV result.color, fragment.fogcoord;\n"
41 int piglit_width
= 50, piglit_height
= 50;
42 int piglit_window_mode
= GLUT_RGBA
| GLUT_ALPHA
| GLUT_DOUBLE
;
44 static PFNGLFOGCOORDFPROC pglFogCoordf
= NULL
;
61 glClear(GL_COLOR_BUFFER_BIT
);
95 for (i
= 0; i
< 4; i
++) {
96 float expected_color
[4];
98 expected_color
[0] = probes
[i
].r
;
99 expected_color
[1] = 0.0;
100 expected_color
[2] = 0.0;
101 expected_color
[3] = 1.0;
103 pass
&= piglit_probe_pixel_rgba(probes
[i
].x
* piglit_width
/ 2,
104 probes
[i
].y
* piglit_height
/ 2,
110 return pass
? PIGLIT_SUCCESS
: PIGLIT_FAILURE
;
114 static void Reshape(int width
, int height
)
116 piglit_width
= width
;
117 piglit_height
= height
;
119 glViewport(0, 0, width
, height
);
120 glMatrixMode(GL_PROJECTION
);
122 glOrtho(0.0, 2.0, 0.0, 2.0, -2.0, 6.0);
123 glScalef(1.0, 1.0, -1.0); // flip z-axis
124 glMatrixMode(GL_MODELVIEW
);
129 piglit_init(int argc
, char **argv
)
132 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
134 glutReshapeFunc(Reshape
);
136 glClearColor(0.3, 0.3, 0.3, 0.3);
138 if (GLEW_VERSION_1_4
) {
139 pglFogCoordf
= glFogCoordf
;
140 } else if (GLEW_EXT_fog_coord
) {
141 pglFogCoordf
= glFogCoordfEXT
;
143 piglit_report_result(PIGLIT_SKIP
);
146 piglit_require_fragment_program();
147 prog
= piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB
, program_text
);
149 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
150 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, prog
);
152 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);
154 Reshape(piglit_width
, piglit_height
);