1 /*
2 * Copyright © 2009 Intel Corporation
3 *
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:
10 *
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
13 * Software.
14 *
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.
22 *
23 * Authors:
24 * Ben Holmes <shranzel@hotmail.com>
25 */
26
27 /*
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.
32 */
33
34 #include "piglit-util-gl.h"
35
36 PIGLIT_GL_TEST_CONFIG_BEGIN
37
38 config.supports_gl_compat_version = 10;
39
40 config.window_width = 400;
41 config.window_height = 300;
42 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
43
44 PIGLIT_GL_TEST_CONFIG_END
45
46 void
piglit_init(int argc,char ** argv)47 piglit_init(int argc, char **argv)
48 {
49
50 piglit_require_extension("GL_EXT_provoking_vertex");
51 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
52
53 glShadeModel(GL_FLAT);
54 glClearColor(0.2, 0.2, 0.2, 1.0);
55
56 }
57
58 enum piglit_result
piglit_display(void)59 piglit_display(void)
60 {
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;
65
66 glClear(GL_COLOR_BUFFER_BIT);
67 glProvokingVertexEXT(GL_FIRST_VERTEX_CONVENTION_EXT);
68 /* lower triangle: counter-clockwise */
69 glBegin(GL_TRIANGLES);
70 glColor3fv(red);
71 glVertex3i(125, 85, 0);
72 glColor3fv(green);
73 glVertex3i(175, 85, 0);
74 glColor3fv(blue);
75 glVertex3i(150, 110, 0);
76 glEnd();
77
78 /* upper triangle: clockwise */
79 glBegin(GL_TRIANGLES);
80 glColor3fv(red);
81 glVertex3i(125, 165, 0);
82 glColor3fv(blue);
83 glVertex3i(150, 190, 0);
84 glColor3fv(green);
85 glVertex3i(175, 165, 0);
86 glEnd();
87
88 glProvokingVertexEXT(GL_LAST_VERTEX_CONVENTION_EXT);
89 /* lower triangle: counter-clockwise */
90 glBegin(GL_TRIANGLES);
91 glColor3fv(red);
92 glVertex3i(200, 85, 0);
93 glColor3fv(green);
94 glVertex3i(250, 85, 0);
95 glColor3fv(blue);
96 glVertex3i(225, 110, 0);
97 glEnd();
98
99 /* upper triangle: clockwise */
100 glBegin(GL_TRIANGLES);
101 glColor3fv(green);
102 glVertex3i(250, 165, 0);
103 glColor3fv(red);
104 glVertex3i(200, 165, 0);
105 glColor3fv(blue);
106 glVertex3i(225, 190, 0);
107 glEnd();
108
109 pass = pass && piglit_probe_pixel_rgb(150, 90, red);
110 pass = pass && piglit_probe_pixel_rgb(150, 170, red);
111
112 pass = pass && piglit_probe_pixel_rgb(225, 90, blue);
113 pass = pass && piglit_probe_pixel_rgb(225, 170, blue);
114
115 glFinish();
116 piglit_present_results();
117
118 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
119 }
120