Add more structure constructor tests.
[piglit/hramrach.git] / tests / general / provoking-vertex.c
blob701686b8fa901768bc9252467588d6dd096037d2
1 /*
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
13 * Software.
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.
23 * Authors:
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.h"
36 int piglit_width = 400, piglit_height = 300;
37 int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
39 #ifndef APIENTRY
40 #define APIENTRY
41 #endif
42 #ifndef APIENTRYP
43 #define APIENTRYP APIENTRY *
44 #endif
45 #ifndef GL_EXT_provoking_vertex
46 #define GL_EXT_provoking_vertex
47 #define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C
48 #define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D
49 #define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E
50 #define GL_PROVOKING_VERTEX_EXT 0x8E4F
51 typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode);
52 #endif
54 static PFNGLPROVOKINGVERTEXEXTPROC pglProvokingVertexEXT = 0;
56 void
57 piglit_init(int argc, char **argv)
60 piglit_require_extension("GL_EXT_provoking_vertex");
61 pglProvokingVertexEXT = (PFNGLPROVOKINGVERTEXEXTPROC)
62 piglit_get_proc_address("glProvokingVertexEXT");
64 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
66 glShadeModel(GL_FLAT);
68 glClearColor(0.2, 0.2, 0.2, 1.0);
72 enum piglit_result
73 piglit_display(void)
75 float red[3] = {1.0, 0.0, 0.0};
76 float blue[3] = {0.0, 0.0, 1.0};
77 GLboolean pass = GL_TRUE;
79 glClear(GL_COLOR_BUFFER_BIT);
80 pglProvokingVertexEXT(GL_FIRST_VERTEX_CONVENTION_EXT);
81 glBegin(GL_TRIANGLES);
82 glColor3f(1.0, 0.0, 0.0);
83 glVertex3i(125, 125, 0);
84 glColor3f(0.0, 1.0, 0.0);
85 glVertex3i(175, 125, 0);
86 glColor3f(0.0, 0.0, 1.0);
87 glVertex3i(150, 150, 0);
88 glEnd();
90 pglProvokingVertexEXT(GL_LAST_VERTEX_CONVENTION_EXT);
91 glBegin(GL_TRIANGLES);
92 glColor3f(1.0, 0.0, 0.0);
93 glVertex3i(200, 125, 0);
94 glColor3f(0.0, 1.0, 0.0);
95 glVertex3i(250, 125, 0);
96 glColor3f(0.0, 0.0, 1.0);
97 glVertex3i(225, 150, 0);
98 glEnd();
100 pass = pass && piglit_probe_pixel_rgb(150, 130, red);
101 pass = pass && piglit_probe_pixel_rgb(225, 130, blue);
103 glFinish();
104 glutSwapBuffers();
106 return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;