2 * Copyright © 2009 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
21 * DEALINGS IN THE SOFTWARE.
24 * Ben Holmes <shranzel@hotmail.com>
28 * tests for bug fdo 23746. The bug prevents glUseProgram from working when
29 * called within a display list.
32 #include "piglit-util.h"
34 int piglit_width
= 400, piglit_height
= 300;
35 int piglit_window_mode
= GLUT_RGB
| GLUT_DOUBLE
;
44 static GLfloat vertices
[12] = {150.0, 125.0, 0.0,
49 static const char *vertShaderText
=
52 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
55 static const char *fragShaderTextRed
=
58 " gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
61 static const char *fragShaderTextGreen
=
64 " gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
72 vs
= glCreateShader(GL_VERTEX_SHADER
);
73 fsr
= glCreateShader(GL_FRAGMENT_SHADER
);
74 fsg
= glCreateShader(GL_FRAGMENT_SHADER
);
75 glShaderSource(vs
, 1, (const GLchar
**) &vertShaderText
, NULL
);
76 glShaderSource(fsr
, 1, (const GLchar
**) &fragShaderTextRed
, NULL
);
77 glShaderSource(fsg
, 1, (const GLchar
**) &fragShaderTextGreen
, NULL
);
79 glGetShaderiv(vs
, GL_COMPILE_STATUS
, &stat
);
81 printf("error compiling vertex shader!\n");
85 glGetShaderiv(fsr
, GL_COMPILE_STATUS
, &stat
);
87 printf("error compiling fragment red shader!\n");
92 glGetShaderiv(fsg
, GL_COMPILE_STATUS
, &stat
);
94 printf("error compiling fragment green shader!\n");
98 progr
= glCreateProgram();
99 glAttachShader(progr
, vs
);
100 glAttachShader(progr
, fsr
);
101 glLinkProgram(progr
);
103 progg
= glCreateProgram();
104 glAttachShader(progg
, vs
);
105 glAttachShader(progg
, fsg
);
106 glLinkProgram(progg
);
109 glVertexAttribPointer(0, 3, GL_FLOAT
, GL_FALSE
, 3*sizeof(GLfloat
),
112 glEnableVertexAttribArray(0);
114 list
= glGenLists(1);
115 glNewList(list
, GL_COMPILE
);
122 piglit_init(int argc
, char **argv
)
124 if (!GLEW_VERSION_2_0
) {
125 printf("Requires OpenGL 2.0\n");
126 piglit_report_result(PIGLIT_SKIP
);
129 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);
131 glClearColor(0.2, 0.2, 0.2, 1.0);
139 GLfloat green
[3] = {0.0, 1.0, 0.0};
140 GLboolean pass
= GL_TRUE
;
142 glClear(GL_COLOR_BUFFER_BIT
);
147 glDrawArrays(GL_TRIANGLE_STRIP
,0,4);
149 pass
= piglit_probe_pixel_rgb(125, 150, green
);
154 return pass
? PIGLIT_SUCCESS
: PIGLIT_FAILURE
;