2 * Copyright © 2009 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.
24 * Ben Holmes <shranzel@hotmail.com>
28 * draws two triangles using different colors for each vert(1st-red, 2nd-green,
29 * 3rd-blue). first tri drawn using glProvokingVertexEXT set to
30 * GL_FIRST_VERTEX_CONVENTION_EXT.
31 * Second tri using GL_LAST_VERTEX_CONVENTION_EXT.
34 #include "piglit-util-gl.h"
36 PIGLIT_GL_TEST_CONFIG_BEGIN
38 config
.supports_gl_compat_version
= 10;
40 config
.window_width
= 400;
41 config
.window_height
= 300;
42 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
44 PIGLIT_GL_TEST_CONFIG_END
47 piglit_init(int argc
, char **argv
)
50 piglit_require_extension("GL_EXT_provoking_vertex");
51 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);
53 glShadeModel(GL_FLAT
);
54 glClearColor(0.2, 0.2, 0.2, 1.0);
61 static const float red
[3] = {0.9, 0.0, 0.0};
62 static const float blue
[3] = {0.0, 0.0, 0.9};
63 static const float green
[3] = {0.0, 1.0, 0.0};
64 GLboolean pass
= GL_TRUE
;
66 glClear(GL_COLOR_BUFFER_BIT
);
67 glProvokingVertexEXT(GL_FIRST_VERTEX_CONVENTION_EXT
);
68 /* lower triangle: counter-clockwise */
69 glBegin(GL_TRIANGLES
);
71 glVertex3i(125, 85, 0);
73 glVertex3i(175, 85, 0);
75 glVertex3i(150, 110, 0);
78 /* upper triangle: clockwise */
79 glBegin(GL_TRIANGLES
);
81 glVertex3i(125, 165, 0);
83 glVertex3i(150, 190, 0);
85 glVertex3i(175, 165, 0);
88 glProvokingVertexEXT(GL_LAST_VERTEX_CONVENTION_EXT
);
89 /* lower triangle: counter-clockwise */
90 glBegin(GL_TRIANGLES
);
92 glVertex3i(200, 85, 0);
94 glVertex3i(250, 85, 0);
96 glVertex3i(225, 110, 0);
99 /* upper triangle: clockwise */
100 glBegin(GL_TRIANGLES
);
102 glVertex3i(250, 165, 0);
104 glVertex3i(200, 165, 0);
106 glVertex3i(225, 190, 0);
109 pass
= pass
&& piglit_probe_pixel_rgb(150, 90, red
);
110 pass
= pass
&& piglit_probe_pixel_rgb(150, 170, red
);
112 pass
= pass
&& piglit_probe_pixel_rgb(225, 90, blue
);
113 pass
= pass
&& piglit_probe_pixel_rgb(225, 170, blue
);
116 piglit_present_results();
118 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;