ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / gl-1.5 / get-array-attribs.c
blob6aa3c78327f35c2d349250a37218d04cc1a358ca
1 /*
2 * Copyright (C) 2018 VMware, Inc.
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.
24 /**
25 * Test glGetInteger/Float/Double/Booleanv with vertex array attributes.
28 #include "piglit-util-gl.h"
31 PIGLIT_GL_TEST_CONFIG_BEGIN
32 config.supports_gl_compat_version = 15;
33 config.window_visual = PIGLIT_GL_VISUAL_RGBA;
34 config.khr_no_error_support = PIGLIT_NO_ERRORS;
35 PIGLIT_GL_TEST_CONFIG_END
38 static bool
39 test_get(GLenum pname, GLint expectedValue)
41 GLint i;
42 GLfloat f;
43 GLdouble d;
44 GLboolean b;
45 bool pass = true;
47 glGetIntegerv(pname, &i);
48 glGetFloatv(pname, &f);
49 glGetDoublev(pname, &d);
50 glGetBooleanv(pname, &b);
52 if (i != expectedValue) {
53 printf("glGetIntegerv(%s) failed: expected %d, got %d\n",
54 piglit_get_gl_enum_name(pname),
55 expectedValue, i);
56 pass = false;
59 if (f != (GLfloat) expectedValue) {
60 printf("glGetFloatv(%s) failed: expected %f, got %f\n",
61 piglit_get_gl_enum_name(pname),
62 (GLfloat) expectedValue, f);
63 pass = false;
66 if (d != (GLdouble) expectedValue) {
67 printf("glGetDoublev(%s) failed: expected %f, got %f\n",
68 piglit_get_gl_enum_name(pname),
69 (GLdouble) expectedValue, f);
70 pass = false;
73 if (b != (GLboolean) !!expectedValue) {
74 printf("glGetBooleanv(%s) failed: expected %d, got %d\n",
75 piglit_get_gl_enum_name(pname),
76 !!expectedValue, b);
77 pass = false;
80 return pass;
84 enum piglit_result
85 piglit_display(void)
87 /* nothing */
88 return PIGLIT_PASS;
92 void
93 piglit_init(int argc, char **argv)
95 bool pass = true;
96 GLubyte dummy[100];
98 glVertexPointer(2, GL_FLOAT, 12, dummy);
99 glNormalPointer(GL_FLOAT, 0, dummy);
100 glColorPointer(4, GL_UNSIGNED_BYTE, 16, dummy);
101 glSecondaryColorPointer(3, GL_SHORT, 32, dummy);
102 glTexCoordPointer(3, GL_SHORT, 18, dummy);
103 glEdgeFlagPointer(4, dummy);
104 glIndexPointer(GL_SHORT, 10, dummy);
105 glFogCoordPointer(GL_FLOAT, 8, dummy);
107 pass = test_get(GL_VERTEX_ARRAY_SIZE, 2) && pass;
108 pass = test_get(GL_VERTEX_ARRAY_TYPE, GL_FLOAT) && pass;
109 pass = test_get(GL_VERTEX_ARRAY_STRIDE, 12) && pass;
111 pass = test_get(GL_NORMAL_ARRAY_TYPE, GL_FLOAT) && pass;
112 pass = test_get(GL_NORMAL_ARRAY_STRIDE, 0) && pass;
114 pass = test_get(GL_COLOR_ARRAY_SIZE, 4) && pass;
115 pass = test_get(GL_COLOR_ARRAY_TYPE, GL_UNSIGNED_BYTE) && pass;
116 pass = test_get(GL_COLOR_ARRAY_STRIDE, 16) && pass;
118 pass = test_get(GL_SECONDARY_COLOR_ARRAY_SIZE, 3) && pass;
119 pass = test_get(GL_SECONDARY_COLOR_ARRAY_TYPE, GL_SHORT) && pass;
120 pass = test_get(GL_SECONDARY_COLOR_ARRAY_STRIDE, 32) && pass;
122 pass = test_get(GL_TEXTURE_COORD_ARRAY_SIZE, 3) && pass;
123 pass = test_get(GL_TEXTURE_COORD_ARRAY_TYPE, GL_SHORT) && pass;
124 pass = test_get(GL_TEXTURE_COORD_ARRAY_STRIDE, 18) && pass;
126 pass = test_get(GL_EDGE_FLAG_ARRAY_STRIDE, 4) && pass;
128 pass = test_get(GL_INDEX_ARRAY_TYPE, GL_SHORT) && pass;
129 pass = test_get(GL_INDEX_ARRAY_STRIDE, 10) && pass;
131 pass = test_get(GL_FOG_COORD_ARRAY_TYPE, GL_FLOAT) && pass;
132 pass = test_get(GL_FOG_COORD_ARRAY_STRIDE, 8) && pass;
134 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);