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
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
24 * Eric Anholt <eric@anholt.net>
28 /** @file useprogram-flushverts-2.c
30 * Tests that a change in the shader results in previous vertices
31 * getting flushed correctly with the previous shader.
34 #include "piglit-util-gl.h"
36 PIGLIT_GL_TEST_CONFIG_BEGIN
38 config
.supports_gl_compat_version
= 10;
40 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
42 PIGLIT_GL_TEST_CONFIG_END
44 static GLint prog1
, prog2
;
49 GLboolean pass
= GL_TRUE
;
50 float green
[4] = {0.0, 1.0, 0.0, 0.0};
51 float blue
[4] = {0.0, 0.0, 1.0, 0.0};
54 glBegin(GL_TRIANGLE_FAN
);
55 glVertex2f(-1.0, -1.0);
56 glVertex2f(-0.5, -1.0);
57 glVertex2f(-0.5, 1.0);
58 glVertex2f(-1.0, 1.0);
62 glBegin(GL_TRIANGLE_FAN
);
63 glVertex2f(-0.5, -1.0);
64 glVertex2f( 0.0, -1.0);
65 glVertex2f( 0.0, 1.0);
66 glVertex2f(-0.5, 1.0);
70 glBegin(GL_TRIANGLE_FAN
);
71 glVertex2f(0.0, -1.0);
72 glVertex2f(0.5, -1.0);
78 glBegin(GL_TRIANGLE_FAN
);
79 glVertex2f(0.5, -1.0);
80 glVertex2f(1.0, -1.0);
85 pass
&= piglit_probe_pixel_rgba(piglit_width
* 1 / 8, piglit_height
/ 2,
87 pass
&= piglit_probe_pixel_rgba(piglit_width
* 3 / 8, piglit_height
/ 2,
89 pass
&= piglit_probe_pixel_rgba(piglit_width
* 5 / 8, piglit_height
/ 2,
91 pass
&= piglit_probe_pixel_rgba(piglit_width
* 7 / 8, piglit_height
/ 2,
94 piglit_present_results();
96 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
100 piglit_init(int argc
, char **argv
)
103 const char *vs_source
=
106 " gl_Position = gl_Vertex;\n"
108 const char *fs1_source
=
111 " gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);\n"
113 const char *fs2_source
=
116 " gl_FragColor = vec4(0.0, 0.0, 1.0, 0.0);\n"
119 piglit_require_gl_version(20);
121 vs
= piglit_compile_shader_text(GL_VERTEX_SHADER
, vs_source
);
122 fs1
= piglit_compile_shader_text(GL_FRAGMENT_SHADER
, fs1_source
);
123 fs2
= piglit_compile_shader_text(GL_FRAGMENT_SHADER
, fs2_source
);
124 prog1
= piglit_link_simple_program(vs
, fs1
);
125 prog2
= piglit_link_simple_program(vs
, fs2
);