glx: don't fail test if the X server is inconsistent
[piglit.git] / tests / general / varray-disabled.c
blobd7b7b83b3503785088935516de9bdcdae47d17c9
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 DEALINGS
21 * IN THE SOFTWARE.
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
28 /**
29 * @file varray-disabled.c
31 * Test whether no vertices are drawn when we call DrawArrays with no
32 * vertex array enabled.
34 * http://bugs.freedesktop.org/show_bug.cgi?id=19911
37 #include "piglit-util-gl.h"
39 PIGLIT_GL_TEST_CONFIG_BEGIN
41 config.supports_gl_compat_version = 10;
43 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
44 config.khr_no_error_support = PIGLIT_NO_ERRORS;
46 PIGLIT_GL_TEST_CONFIG_END
48 static void
49 set_colors(GLfloat *color_array, GLfloat *color)
51 int i;
53 for (i = 0; i < 4; i++) {
54 color_array[i * 4 + 0] = color[0];
55 color_array[i * 4 + 1] = color[1];
56 color_array[i * 4 + 2] = color[2];
57 color_array[i * 4 + 3] = 1.0;
61 enum piglit_result
62 piglit_display(void)
64 GLfloat vertices[4][2];
65 GLfloat colors[16];
66 GLboolean pass = GL_TRUE;
67 GLfloat red[3] = {1.0, 0.0, 0.0};
68 GLfloat green[3] = {0.0, 1.0, 0.0};
69 GLfloat blue[3] = {0.0, 0.0, 1.0};
70 GLfloat black[3] = {0.0, 0.0, 0.0};
72 piglit_ortho_projection(1.0, 1.0, GL_FALSE);
74 glClearColor(0.0, 0.0, 0.0, 0.0);
75 glClear(GL_COLOR_BUFFER_BIT);
77 glColorPointer(4, GL_FLOAT, 0, colors);
78 glEnableClientState(GL_COLOR_ARRAY);
80 /* Draw the vertices enabled once on the left side for sanity */
81 vertices[0][0] = 0.0;
82 vertices[0][1] = 0.0;
83 vertices[1][0] = 0.3;
84 vertices[1][1] = 0.0;
85 vertices[2][0] = 0.3;
86 vertices[2][1] = 1.0;
87 vertices[3][0] = 0.0;
88 vertices[3][1] = 1.0;
89 glVertexPointer(2, GL_FLOAT, 0, vertices);
90 glEnableClientState(GL_VERTEX_ARRAY);
91 set_colors(colors, red);
92 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
94 /* Now disable and draw again. */
95 vertices[0][0] = 0.3;
96 vertices[0][1] = 0.0;
97 vertices[1][0] = 0.7;
98 vertices[1][1] = 0.0;
99 vertices[2][0] = 0.7;
100 vertices[2][1] = 1.0;
101 vertices[3][0] = 0.3;
102 vertices[3][1] = 1.0;
103 /* This NULL pointer set was key in triggering the bug reported. */
104 glVertexPointer (2, GL_FLOAT, 0, NULL);
105 glDisableClientState(GL_VERTEX_ARRAY);
106 glDisableClientState(GL_COLOR_ARRAY);
107 set_colors(colors, green);
108 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
110 /* Now draw again enabled, to make sure the hardware hasn't given
111 * up on us.
113 vertices[0][0] = 0.7;
114 vertices[0][1] = 0.0;
115 vertices[1][0] = 1.0;
116 vertices[1][1] = 0.0;
117 vertices[2][0] = 1.0;
118 vertices[2][1] = 1.0;
119 vertices[3][0] = 0.7;
120 vertices[3][1] = 1.0;
121 glVertexPointer(2, GL_FLOAT, 0, vertices);
122 glEnableClientState(GL_VERTEX_ARRAY);
123 glEnableClientState(GL_COLOR_ARRAY);
124 set_colors(colors, blue);
125 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
127 pass &= piglit_probe_pixel_rgb(piglit_width * 1 / 6,
128 piglit_height / 2, red);
129 pass &= piglit_probe_pixel_rgb(piglit_width * 3 / 6,
130 piglit_height / 2, black);
131 pass &= piglit_probe_pixel_rgb(piglit_width * 5 / 6,
132 piglit_height / 2, blue);
134 piglit_present_results();
136 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
139 void
140 piglit_init(int argc, char *argv[])