glx-multithread-texture: Avoid front-buffer rendering.
[piglit.git] / tests / shaders / glsl-max-vertex-attrib.c
bloba7d530657ec216f1bad66ac37179ac4a663b54ba
1 /*
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
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 DEALINGS
21 * IN THE SOFTWARE.
25 /**
26 * \file glsl-max-vertex-attrib.c
27 * Test setting vertex attrib value of GL_MAX_VERTEX_ATTRIBS attrib
29 * Queries the value for GL_MAX_VERTEX_ATTRIBS and uses that as index
30 * to set a value. GL specification states that GL_INVALID_VALUE should
31 * occur if index >= GL_MAX_VERTEX_ATTRIBS.
33 * \author Sun Yi <yi.sun@intel.com>
34 * \author Tapani Pälli <tapani.palli@intel.com>
37 #include "piglit-util-gl.h"
39 PIGLIT_GL_TEST_CONFIG_BEGIN
41 config.supports_gl_compat_version = 10;
43 config.window_width = 250;
44 config.window_height = 250;
45 config.window_visual = PIGLIT_GL_VISUAL_RGB;
47 PIGLIT_GL_TEST_CONFIG_END
49 static int test = 0;
51 #define CHECK_GL_INVALID_VALUE \
52 if (glGetError() != GL_INVALID_VALUE) return PIGLIT_FAIL; \
53 else printf("glsl-max-vertex-attrib test %d passed\n", ++test);
55 static const char *vShaderString =
56 "attribute float pos;\n"
57 "void main()\n"
58 "{\n"
59 " gl_Position = vec4(pos, 0.0, 0.0, 1.0);\n"
60 "}\n";
62 static const char *fShaderString =
63 "void main()\n"
64 "{\n"
65 " gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
66 "}\n";
68 enum piglit_result piglit_display(void)
70 GLvoid *datap;
71 GLint intv[] = { 1, 1, 1, 1 };
72 GLfloat floatv[] = { 1.0, 1.0, 1.0, 1.0 };
73 GLfloat quad[] = { -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0 };
75 GLsizei length;
76 GLint size;
77 GLenum type;
78 GLchar buffer[64];
80 GLuint program;
81 int maxAttribCount;
83 /* --- valid program needed for some of the functions --- */
84 program = piglit_build_simple_program(vShaderString, fShaderString);
85 piglit_check_gl_error(GL_NO_ERROR);
87 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribCount);
89 /* --- tests begin here --- */
91 glVertexAttrib1f(maxAttribCount, floatv[0]);
92 CHECK_GL_INVALID_VALUE;
94 glVertexAttrib2f(maxAttribCount, floatv[0], floatv[1]);
95 CHECK_GL_INVALID_VALUE;
97 glVertexAttrib3f(maxAttribCount, floatv[0], floatv[1], floatv[2]);
98 CHECK_GL_INVALID_VALUE;
100 glVertexAttrib4f(maxAttribCount, floatv[0], floatv[1], floatv[2],
101 floatv[3]);
102 CHECK_GL_INVALID_VALUE;
104 glVertexAttrib1fv(maxAttribCount, floatv);
105 CHECK_GL_INVALID_VALUE;
107 glVertexAttrib2fv(maxAttribCount, floatv);
108 CHECK_GL_INVALID_VALUE;
110 glVertexAttrib3fv(maxAttribCount, floatv);
111 CHECK_GL_INVALID_VALUE;
113 glVertexAttrib4fv(maxAttribCount, floatv);
114 CHECK_GL_INVALID_VALUE;
116 glVertexAttribPointer(maxAttribCount, 2, GL_FLOAT, GL_FALSE, 0, quad);
117 CHECK_GL_INVALID_VALUE;
119 glBindAttribLocation(program, maxAttribCount, "pos");
120 CHECK_GL_INVALID_VALUE;
122 glEnableVertexAttribArray(maxAttribCount);
123 CHECK_GL_INVALID_VALUE;
125 glDisableVertexAttribArray(maxAttribCount);
126 CHECK_GL_INVALID_VALUE;
128 glGetVertexAttribfv(maxAttribCount, GL_CURRENT_VERTEX_ATTRIB, floatv);
129 CHECK_GL_INVALID_VALUE;
131 glGetVertexAttribiv(maxAttribCount, GL_CURRENT_VERTEX_ATTRIB, intv);
132 CHECK_GL_INVALID_VALUE;
134 glGetVertexAttribPointerv(maxAttribCount, GL_VERTEX_ATTRIB_ARRAY_POINTER, &datap);
135 CHECK_GL_INVALID_VALUE;
137 glGetActiveAttrib(program, maxAttribCount, 64, &length, &size, &type, buffer);
138 CHECK_GL_INVALID_VALUE;
140 return PIGLIT_PASS;
143 void piglit_init(int argc, char **argv)
145 piglit_require_gl_version(20);