cmake: move defaults into the per-platform section
[piglit.git] / tests / shaders / glsl-dlist-getattriblocation.c
blobb90e847e3a31dbc6950b6228ce63ad4dc8197dc4
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-gl.h"
35 PIGLIT_GL_TEST_CONFIG_BEGIN
37 config.supports_gl_compat_version = 10;
39 config.window_visual = PIGLIT_GL_VISUAL_RGB;
41 PIGLIT_GL_TEST_CONFIG_END
43 static const GLchar *vertShaderText =
44 "attribute vec4 attrib;\n"
45 "void main()\n"
46 "{\n"
47 " gl_Position = gl_ModelViewProjectionMatrix * attrib;\n"
48 "} \n";
51 enum piglit_result
52 piglit_display(void)
54 GLboolean pass = GL_TRUE;
55 GLint vs;
56 GLint prog;
57 GLint stat;
58 GLint attrib_loc;
59 GLint attrib_loc_in_dlist;
62 vs = glCreateShader(GL_VERTEX_SHADER);
63 glShaderSource(vs, 1, &vertShaderText, NULL);
65 glCompileShader(vs);
66 glGetShaderiv(vs, GL_COMPILE_STATUS, &stat);
67 if (!stat) {
68 printf("error compiling vertex shader1!\n");
69 exit(1);
72 prog = glCreateProgram();
73 glAttachShader(prog, vs);
74 glBindAttribLocation(prog, 1, "attrib");
75 glLinkProgram(prog);
77 attrib_loc = glGetAttribLocation(prog, "attrib");
78 if (!piglit_automatic)
79 printf("attrib_loc = %d\n", attrib_loc);
81 glNewList(1, GL_COMPILE);
83 /* Notice the trickery here! glBindAttribLocation does not take effect
84 * until glLinkProgram is called!
86 glBindAttribLocation(prog, 2, "attrib");
87 attrib_loc_in_dlist = glGetAttribLocation(prog, "attrib");
89 if (!piglit_automatic)
90 printf("attrib_loc_in_dlist = %d\n", attrib_loc_in_dlist);
91 glEndList();
93 pass = (attrib_loc == 1) && (attrib_loc == attrib_loc_in_dlist);
94 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
98 void
99 piglit_init(int argc, char **argv)
101 piglit_require_gl_version(20);
103 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);