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
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
24 * Eric Anholt <eric@anholt.net>
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.h"
39 int piglit_width
= 128, piglit_height
= 128;
40 int piglit_window_mode
= GLUT_RGB
| GLUT_DOUBLE
;
45 static const char *badprog
=
48 "MOV result.position, vertex.position;\n";
49 static const GLfloat vertcoords
[4][3] = {
58 /* Try the bad vertex program, and make sure we get an error */
59 glProgramStringARB(GL_VERTEX_PROGRAM_ARB
,
60 GL_PROGRAM_FORMAT_ASCII_ARB
,
62 (const GLubyte
*) badprog
);
65 if (err
!= GL_INVALID_OPERATION
) {
66 printf("Unexpected OpenGL error state %d with bad vertex "
68 printf("Expected: %d\n", GL_INVALID_OPERATION
);
75 /* Check that we correctly produce GL_INVALID_OPERATION when rendering
76 * with an invalid/non-existant program.
78 glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 99);
79 glEnable(GL_VERTEX_PROGRAM_ARB
);
81 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
83 glTexCoord2f(0, 0); glVertex2f(-0.25, -0.25);
84 glTexCoord2f(1, 0); glVertex2f( 0.25, -0.25);
85 glTexCoord2f(1, 1); glVertex2f( 0.25, 0.25);
86 glTexCoord2f(0, 1); glVertex2f(-0.25, 0.25);
90 if (err
!= GL_INVALID_OPERATION
) {
91 printf("Unexpected OpenGL error state %d in glBegin() "
92 "with bad vertex program.\n", err
);
93 printf("Expected: %d\n", GL_INVALID_OPERATION
);
100 /* Check that we correctly produce GL_INVALID_OPERATION when doing
101 * glDrawArrays with an invalid/non-existant program.
104 glVertexPointer(3, GL_FLOAT
, 0, vertcoords
);
105 glEnableClientState(GL_VERTEX_ARRAY
);
106 glDrawArrays(GL_POLYGON
, 0, 4);
108 glDisableClientState(GL_VERTEX_ARRAY
);
110 if (err
!= GL_INVALID_OPERATION
) {
111 printf("Unexpected OpenGL error state %d in glDrawArrays() "
112 "with bad vertex program.\n", err
);
113 printf("Expected: %d\n", GL_INVALID_OPERATION
);
120 return failed
? PIGLIT_FAILURE
: PIGLIT_SUCCESS
;
123 void piglit_init(int argc
, char **argv
)
125 piglit_automatic
= GL_TRUE
;
127 piglit_require_vertex_program();