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
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
21 * DEALINGS IN THE SOFTWARE.
25 * \file glsl-dlist-getattriblocation.c
27 * Validate the behavior of \c glGetAttribLocation while compiling a display
28 * list. See also bugzilla #15202.
30 * \author Ian Romanick <ian.d.romanick@intel.com>
33 #include "piglit-util.h"
34 #include "piglit-framework.h"
36 int piglit_window_mode
= GLUT_RGB
;
37 int piglit_width
= 100;
38 int piglit_height
= 100;
40 static const GLchar
*vertShaderText
=
41 "attribute vec4 attrib;\n"
44 " gl_Position = gl_ModelViewProjectionMatrix * attrib;\n"
51 GLboolean pass
= GL_TRUE
;
56 GLint attrib_loc_in_dlist
;
59 vs
= glCreateShader(GL_VERTEX_SHADER
);
60 glShaderSource(vs
, 1, &vertShaderText
, NULL
);
63 glGetShaderiv(vs
, GL_COMPILE_STATUS
, &stat
);
65 printf("error compiling vertex shader1!\n");
69 prog
= glCreateProgram();
70 glAttachShader(prog
, vs
);
71 glBindAttribLocation(prog
, 1, "attrib");
74 attrib_loc
= glGetAttribLocation(prog
, "attrib");
75 if (!piglit_automatic
)
76 printf("attrib_loc = %d\n", attrib_loc
);
78 glNewList(1, GL_COMPILE
);
80 /* Notice the trickery here! glBindAttribLocation does not take effect
81 * until glLinkProgram is called!
83 glBindAttribLocation(prog
, 2, "attrib");
84 attrib_loc_in_dlist
= glGetAttribLocation(prog
, "attrib");
86 if (!piglit_automatic
)
87 printf("attrib_loc_in_dlist = %d\n", attrib_loc_in_dlist
);
90 pass
= (attrib_loc
== 1) && (attrib_loc
== attrib_loc_in_dlist
);
91 return pass
? PIGLIT_SUCCESS
: PIGLIT_FAILURE
;
96 piglit_init(int argc
, char **argv
)
98 if (!GLEW_VERSION_2_0
) {
99 printf("Requires OpenGL 2.0\n");
100 piglit_report_result(PIGLIT_SKIP
);
104 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);