summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/all.tests1
-rw-r--r--tests/spec/arb_es2_compatibility/CMakeLists.gl.txt1
-rw-r--r--tests/spec/arb_es2_compatibility/arb_es2_compatibility-fixed-type.c142
3 files changed, 144 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests
index 6828de063..8ece55509 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -691,6 +691,7 @@ add_plain_test(arb_es2_compatibility, 'arb_es2_compatibility-drawbuffers')
add_plain_test(arb_es2_compatibility, 'arb_es2_compatibility-maxvectors')
add_plain_test(arb_es2_compatibility, 'arb_es2_compatibility-shadercompiler')
add_plain_test(arb_es2_compatibility, 'arb_es2_compatibility-releaseshadercompiler')
+add_plain_test(arb_es2_compatibility, 'arb_es2_compatibility-fixed-type')
# Group ARB_draw_instanced
arb_draw_instanced = Group()
diff --git a/tests/spec/arb_es2_compatibility/CMakeLists.gl.txt b/tests/spec/arb_es2_compatibility/CMakeLists.gl.txt
index cd0390ae9..aad89144c 100644
--- a/tests/spec/arb_es2_compatibility/CMakeLists.gl.txt
+++ b/tests/spec/arb_es2_compatibility/CMakeLists.gl.txt
@@ -21,5 +21,6 @@ add_executable (arb_es2_compatibility-maxvectors arb_es2_compatibility-maxvector
add_executable (arb_es2_compatibility-releaseshadercompiler arb_es2_compatibility-releaseshadercompiler.c)
add_executable (arb_es2_compatibility-shadercompiler arb_es2_compatibility-shadercompiler.c)
add_executable (arb_es2_compatibility-getshaderprecisionformat arb_es2_compatibility-getshaderprecisionformat.c)
+add_executable (arb_es2_compatibility-fixed-type arb_es2_compatibility-fixed-type.c)
# vim: ft=cmake:
diff --git a/tests/spec/arb_es2_compatibility/arb_es2_compatibility-fixed-type.c b/tests/spec/arb_es2_compatibility/arb_es2_compatibility-fixed-type.c
new file mode 100644
index 000000000..6f3ff99ab
--- /dev/null
+++ b/tests/spec/arb_es2_compatibility/arb_es2_compatibility-fixed-type.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright © 2011 Marek Olšák <maraeo@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "piglit-util.h"
+#include <stdarg.h>
+
+int piglit_width = 250, piglit_height = 250;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA;
+
+static unsigned verts[4*4*4];
+
+static unsigned opos[8] = {
+ 50, 50,
+ 150, 50,
+ 50, 150,
+ 150, 150
+};
+
+static float ocol[16] = {
+ 0.1, 0.5, 0.9, 0.4,
+ 0.3, 0.95, 0.1, 0.6,
+ 0.8, 0.45, 0, 0,
+ 0.6, 0.6, 0.35, 0.15
+};
+
+static unsigned vpos[8] = {
+ 0, 0,
+ 50, 0,
+ 50, 50,
+ 0, 50
+};
+
+static const char *vertShaderText =
+ "void main()\n"
+ "{ \n"
+ " gl_Position = gl_ModelViewProjectionMatrix * floor(gl_Vertex);\n"
+ " gl_FrontColor = fract(gl_Vertex);\n"
+ "} \n";
+
+static void expect_error(GLenum expect, const char * where, ...)
+{
+ GLenum error = glGetError();
+ if (error != expect) {
+ va_list va;
+
+ fprintf(stderr, "Expected OpenGL error 0x%04x, got 0x%04x\nat: ", expect, error);
+
+ va_start(va, where);
+ vfprintf(stderr, where, va);
+ va_end(va);
+ fprintf(stderr, "\n");
+
+ piglit_report_result(PIGLIT_FAIL);
+ }
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLuint vs, prog;
+ int i,j;
+
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
+ piglit_require_extension("GL_ARB_ES2_compatibility");
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+ glClearColor(0.2, 0.2, 0.2, 0.2);
+
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vertShaderText);
+ prog = piglit_link_simple_program(vs, 0);
+
+ glUseProgram(prog);
+
+ glVertexPointer(4, GL_FIXED, 0, verts);
+ expect_error(GL_INVALID_ENUM, "glVertexPointer should not accept GL_FIXED.");
+ glNormalPointer(GL_FIXED, 0, verts);
+ expect_error(GL_INVALID_ENUM, "glNormalPointer should not accept GL_FIXED.");
+ glColorPointer(4, GL_FIXED, 0, verts);
+ expect_error(GL_INVALID_ENUM, "glColorPointer should not accept GL_FIXED.");
+ glTexCoordPointer(4, GL_FIXED, 0, verts);
+ expect_error(GL_INVALID_ENUM, "glTexCoordPointer should not accept GL_FIXED.");
+
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 4, GL_FIXED, GL_FALSE, 0, verts);
+ expect_error(GL_NO_ERROR, "glVertexAttribPointer should accept GL_FIXED.");
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ verts[(i*4+j)*4+0] = ((opos[i*2+0] + vpos[j*2+0]) << 16) |
+ (unsigned)(ocol[i*4+0] * 65535);
+ verts[(i*4+j)*4+1] = ((opos[i*2+1] + vpos[j*2+1]) << 16) |
+ (unsigned)(ocol[i*4+1] * 65535);
+ verts[(i*4+j)*4+2] = (unsigned)(ocol[i*4+2] * 65535);
+ verts[(i*4+j)*4+3] = (1 << 16) |
+ (unsigned)(ocol[i*4+3] * 65535);
+ }
+ }
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ GLboolean pass = GL_TRUE;
+ int i;
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glDrawArrays(GL_QUADS, 0, 16);
+
+ for (i = 0; i < 4; i++) {
+ pass = piglit_probe_pixel_rgba(opos[i*2]+25, opos[i*2+1]+25, &ocol[i*4]) && pass;
+ }
+
+ glutSwapBuffers();
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}