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
25 * \file glsl-link-initializer-01.c
26 * Test conflicting variable initializers.
28 * Each of the 3 shaders involved in this test have a global variable called
29 * \c global_variable. Two of the shaders have (differing) initializers for
30 * this variable, and the other lacks an initalizer. The test verifies that
31 * linking the 3 shaders together results in an error due to the conflicting
34 * \author Ian Romanick
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
;
45 PIGLIT_GL_TEST_CONFIG_END
47 static const GLfloat verts
[12] = {
54 static const char *vs_code
=
57 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
60 static const char *fs_code
=
63 " gl_FragColor = gl_LightModel.ambient;\n"
68 piglit_init(int argc
, char **argv
)
72 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);
74 piglit_require_gl_version(20);
76 vs
= piglit_compile_shader_text(GL_VERTEX_SHADER
, vs_code
);
77 fs
= piglit_compile_shader_text(GL_FRAGMENT_SHADER
, fs_code
);
78 prog
= piglit_link_simple_program(vs
, fs
);
82 glVertexAttribPointer(0, 2, GL_FLOAT
, GL_FALSE
, 2 * sizeof(GLfloat
),
84 glEnableVertexAttribArray(0);
91 GLboolean pass
= GL_TRUE
;
92 static const GLfloat green
[4] = { 0.0, 1.0, 0.0, 1.0 };
94 glClearColor(0.5, 0.5, 0.5, 1.0);
95 glClear(GL_COLOR_BUFFER_BIT
);
97 glLightModelfv(GL_LIGHT_MODEL_AMBIENT
, green
);
99 glDrawArrays(GL_TRIANGLE_FAN
, 0, 4);
101 pass
= pass
&& piglit_probe_pixel_rgb(15, 15, green
);
103 piglit_present_results();
105 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;