cl: Don't use device_infos if num_device_infos == 0
[piglit.git] / tests / general / quad-invariance.c
blob95cdfafe443f8356de7c85ef7edf4ec6af486336
1 /*
2 * Copyright © 2010 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 DEALINGS
21 * IN THE SOFTWARE.
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
28 /**
29 * @file quad-invariance.c
31 * Test whether quad rasterization changes when drawing one or more
32 * than one quad.
34 * This is not strictly required by conformance, but seems to be in
35 * the spirit of the invariance rules. As a result, failure of this
36 * test is only a warning.
39 #include "piglit-util-gl.h"
41 PIGLIT_GL_TEST_CONFIG_BEGIN
43 config.supports_gl_compat_version = 10;
45 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
46 config.khr_no_error_support = PIGLIT_NO_ERRORS;
48 PIGLIT_GL_TEST_CONFIG_END
50 enum piglit_result
51 piglit_display(void)
53 GLboolean pass = GL_TRUE;
54 float verts[12][2] = {
55 /* prim 1: left half of screen. */
56 {-1.0, -1.0},
57 { 0.0, -1.0},
58 { 0.0, 1.0},
59 {-1.0, 1.0},
60 /* prim 2: right half of screen. */
61 { 0.0, -1.0},
62 { 1.0, -1.0},
63 { 1.0, 1.0},
64 { 0.0, 1.0},
65 /* prim 3: somewhere off the screen. */
66 { 2.0, -1.0},
67 { 3.0, -1.0},
68 { 3.0, 1.0},
69 { 2.0, 1.0},
71 float colors[12][4] = {
72 {1.0, 0.0, 0.0, 0.0},
73 {0.0, 1.0, 0.0, 0.0},
74 {0.0, 0.0, 1.0, 0.0},
75 {1.0, 1.0, 1.0, 0.0},
77 {1.0, 0.0, 0.0, 0.0},
78 {0.0, 1.0, 0.0, 0.0},
79 {0.0, 0.0, 1.0, 0.0},
80 {1.0, 1.0, 1.0, 0.0},
82 {1.0, 0.0, 0.0, 0.0},
83 {0.0, 1.0, 0.0, 0.0},
84 {0.0, 0.0, 1.0, 0.0},
85 {1.0, 1.0, 1.0, 0.0},
87 static GLboolean once = GL_TRUE;
89 glClearColor(0.0, 0.0, 0.0, 0.0);
90 glClear(GL_COLOR_BUFFER_BIT);
92 glColorPointer(4, GL_FLOAT, 0, colors);
93 glEnableClientState(GL_COLOR_ARRAY);
94 glVertexPointer(2, GL_FLOAT, 0, verts);
95 glEnableClientState(GL_VERTEX_ARRAY);
97 /* left: 1 prim */
98 glDrawArrays(GL_QUADS, 0, 4);
100 /* right: 1 prim */
101 glDrawArrays(GL_QUADS, 4, 8);
103 if (once) {
104 printf("Left and right half should match.\n");
105 once = GL_FALSE;
108 pass = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width,
109 piglit_height);
111 piglit_present_results();
113 return pass ? PIGLIT_PASS : PIGLIT_WARN;
116 void
117 piglit_init(int argc, char *argv[])