cmake: move defaults into the per-platform section
[piglit.git] / tests / shaders / vp-bad-program.c
blob433cc2b1d2c45cbb5354ca1597c3818cc16929d0
1 /*
2 * Copyright © 2008 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.
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
28 /**
29 * @file vp-bad-program.c
31 * Tests that the driver reports errors correctly (and doesn't crash) when
32 * fed a bad vertex program.
34 * Wine likes to do that to us to see how strict we are on the VP language.
37 #include "piglit-util-gl.h"
39 PIGLIT_GL_TEST_CONFIG_BEGIN
41 config.supports_gl_compat_version = 10;
43 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
44 config.khr_no_error_support = PIGLIT_HAS_ERRORS;
46 PIGLIT_GL_TEST_CONFIG_END
48 enum piglit_result
49 piglit_display(void)
51 static const char *badprog =
52 "!!ARBvp1.0\n"
53 "NOTANOPCODE;\n"
54 "MOV result.position, vertex.position;\n";
55 static const GLfloat vertcoords[4][3] = {
56 { -0.25, -0.25, 0 },
57 { 0.25, -0.25, 0 },
58 { 0.25, 0.25, 0 },
59 { -0.25, 0.25, 0 }
61 int failed = 0;
62 GLenum err;
64 /* Try the bad vertex program, and make sure we get an error */
65 glProgramStringARB(GL_VERTEX_PROGRAM_ARB,
66 GL_PROGRAM_FORMAT_ASCII_ARB,
67 strlen(badprog),
68 (const GLubyte *) badprog);
70 err = glGetError();
71 if (err != GL_INVALID_OPERATION) {
72 printf("Unexpected OpenGL error state %d with bad vertex "
73 "program.\n", err);
74 printf("Expected: %d\n", GL_INVALID_OPERATION);
75 failed++;
77 while (err != 0)
78 err = glGetError();
81 /* Check that we correctly produce GL_INVALID_OPERATION when rendering
82 * with an invalid/non-existent program.
84 glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 99);
85 glEnable(GL_VERTEX_PROGRAM_ARB);
87 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
88 glBegin(GL_POLYGON);
89 glTexCoord2f(0, 0); glVertex2f(-0.25, -0.25);
90 glTexCoord2f(1, 0); glVertex2f( 0.25, -0.25);
91 glTexCoord2f(1, 1); glVertex2f( 0.25, 0.25);
92 glTexCoord2f(0, 1); glVertex2f(-0.25, 0.25);
93 glEnd();
94 err = glGetError();
96 if (err != GL_INVALID_OPERATION) {
97 printf("Unexpected OpenGL error state %d in glBegin() "
98 "with bad vertex program.\n", err);
99 printf("Expected: %d\n", GL_INVALID_OPERATION);
100 failed++;
102 while (err != 0)
103 err = glGetError();
106 /* Check that we correctly produce GL_INVALID_OPERATION when doing
107 * glDrawArrays with an invalid/non-existent program.
110 glVertexPointer(3, GL_FLOAT, 0, vertcoords);
111 glEnableClientState(GL_VERTEX_ARRAY);
112 glDrawArrays(GL_POLYGON, 0, 4);
113 err = glGetError();
114 glDisableClientState(GL_VERTEX_ARRAY);
116 if (err != GL_INVALID_OPERATION) {
117 printf("Unexpected OpenGL error state %d in glDrawArrays() "
118 "with bad vertex program.\n", err);
119 printf("Expected: %d\n", GL_INVALID_OPERATION);
120 failed++;
122 while (err != 0)
123 err = glGetError();
126 return failed ? PIGLIT_FAIL : PIGLIT_PASS;
129 void piglit_init(int argc, char **argv)
131 piglit_automatic = GL_TRUE;
133 piglit_require_vertex_program();