1 /*
2 * Copyright © 2011 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 DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
25 *
26 */
27
28 /** @file glsl-vs-statechange-1.c
29 *
30 * Tests for a bug that appeared to exist in Mesa 7.11 where the
31 * constant attribute color from the previous fixed function setup
32 * would be used, but was hidden by multiple state updates occurring
33 * per draw call.
34 */
35
36 #include "piglit-util-gl.h"
37
38 PIGLIT_GL_TEST_CONFIG_BEGIN
39
40 config.supports_gl_compat_version = 10;
41
42 config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
43
44 PIGLIT_GL_TEST_CONFIG_END
45
46 const char *vs_source =
47 "void main()\n"
48 "{\n"
49 " gl_Position = gl_Vertex;\n"
50 " gl_FrontColor = vec4(0.0, 0.0, 1.0, 0.0);\n"
51 "}\n";
52
53 static GLint prog;
54
55 enum piglit_result
piglit_display(void)56 piglit_display(void)
57 {
58 bool pass = true;
59 float green[4] = {0, 1, 0, 0};
60 float blue[4] = {0, 0, 1, 0};
61
62 glColor4fv(green);
63 piglit_draw_rect(-1, -1, 1, 2);
64
65 glUseProgram(prog);
66 piglit_draw_rect(0, -1, 1, 2);
67
68 glUseProgram(0);
69
70 pass &= piglit_probe_rect_rgba(0, 0,
71 piglit_width / 2, piglit_height, green);
72 pass &= piglit_probe_rect_rgba(piglit_width / 2, 0,
73 piglit_width / 2, piglit_height, blue);
74
75 piglit_present_results();
76
77 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
78 }
79
80 void
piglit_init(int argc,char ** argv)81 piglit_init(int argc, char **argv)
82 {
83 GLint vs;
84
85 piglit_require_gl_version(20);
86
87 vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
88
89 prog = piglit_link_simple_program(vs, 0);
90
91 glDeleteShader(vs);
92 }
93