glx-multithread-texture: Avoid front-buffer rendering.
[piglit.git] / tests / shaders / vp-ignore-input.c
blob9039338b0449a0fe52e757e62317aa707b95e758
1 /*
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
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
21 * DEALINGS IN THE SOFTWARE.
24 // author: Ben Holmes
27 * draws using a vertex program that ignores inputs and instead just
28 * writes a constant to gl_Position.
31 #include "piglit-util-gl.h"
33 PIGLIT_GL_TEST_CONFIG_BEGIN
35 config.supports_gl_compat_version = 10;
37 config.window_width = 400;
38 config.window_height = 300;
39 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
41 PIGLIT_GL_TEST_CONFIG_END
43 static GLint prog;
44 static GLint fs;
45 static GLint vs;
48 static GLfloat vertices[12] = {150.0, 125.0, 0.0,
49 150.0, 175.0, 0.0,
50 100.0, 125.0, 0.0,
51 100.0, 175.0, 0.0};
53 static const char *vertShaderText =
54 "void main()\n"
55 "{ \n"
56 " gl_Position = vec4(100, 50, 0, 0);\n"
57 "} \n";
59 static const char *fragShaderText =
60 "void main()\n"
61 "{ \n"
62 " gl_FragColor = vec4(0.0, 1.0, 1.0, 1.0);\n"
63 "} \n";
65 static void compileLinkProg(void);
67 void
68 piglit_init(int argc, char **argv)
70 glMatrixMode(GL_PROJECTION);
71 glPushMatrix();
72 glLoadIdentity();
73 glOrtho(0, 400, 0, 300, -1, 1);
75 glMatrixMode(GL_MODELVIEW);
76 glPushMatrix();
77 glLoadIdentity();
79 glClearColor(0.2, 0.2, 0.2, 1.0);
81 piglit_require_gl_version(20);
83 compileLinkProg();
86 static void
87 compileLinkProg(void)
89 GLint stat;
91 vs = glCreateShader(GL_VERTEX_SHADER);
92 fs = glCreateShader(GL_FRAGMENT_SHADER);
93 glShaderSource(vs, 1, (const GLchar **) &vertShaderText, NULL);
94 glShaderSource(fs, 1, (const GLchar **) &fragShaderText, NULL);
95 glCompileShader(vs);
96 glGetShaderiv(vs, GL_COMPILE_STATUS, &stat);
97 if (!stat) {
98 printf("error compiling vertex shader!\n");
99 exit(1);
101 glCompileShader(fs);
102 glGetShaderiv(fs, GL_COMPILE_STATUS, &stat);
103 if (!stat) {
104 printf("error compiling fragment shader!\n");
105 exit(1);
108 prog = glCreateProgram();
109 glAttachShader(prog, vs);
110 glAttachShader(prog, fs);
111 glLinkProgram(prog);
112 glUseProgram(prog);
114 glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3*sizeof(GLfloat),
115 vertices);
117 glEnableVertexAttribArray(0);
121 enum piglit_result
122 piglit_display(void)
124 glClear(GL_COLOR_BUFFER_BIT);
126 glDrawArrays(GL_POINTS, 0, 4);
128 glPushMatrix();
129 glTranslatef(75.0, 0.0, 0.0);
131 glDrawArrays(GL_POINTS, 0, 4);
133 glPopMatrix();
135 glFinish();
136 piglit_present_results();
138 return PIGLIT_PASS;