Add more structure constructor tests.
[piglit/hramrach.git] / tests / shaders / glsl-dlist-getattriblocation.c
blob8a49114a3c4bcb07187da4635d0644d8d3ece9c6
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
21 * DEALINGS IN THE SOFTWARE.
24 /**
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"
42 "void main()\n"
43 "{\n"
44 " gl_Position = gl_ModelViewProjectionMatrix * attrib;\n"
45 "} \n";
48 enum piglit_result
49 piglit_display(void)
51 GLboolean pass = GL_TRUE;
52 GLint vs;
53 GLint prog;
54 GLint stat;
55 GLint attrib_loc;
56 GLint attrib_loc_in_dlist;
59 vs = glCreateShader(GL_VERTEX_SHADER);
60 glShaderSource(vs, 1, &vertShaderText, NULL);
62 glCompileShader(vs);
63 glGetShaderiv(vs, GL_COMPILE_STATUS, &stat);
64 if (!stat) {
65 printf("error compiling vertex shader1!\n");
66 exit(1);
69 prog = glCreateProgram();
70 glAttachShader(prog, vs);
71 glBindAttribLocation(prog, 1, "attrib");
72 glLinkProgram(prog);
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);
88 glEndList();
90 pass = (attrib_loc == 1) && (attrib_loc == attrib_loc_in_dlist);
91 return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
95 void
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);
101 exit(1);
104 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);