glx-multithread-texture: Avoid front-buffer rendering.
[piglit.git] / tests / shaders / glsl-vs-texturematrix-2.c
blob8e68e6082244a15ec9a749c5c4bc3ddcf554c5e9
1 /*
2 * Copyright © 2010 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 /** @file glsl-vs-texturematrix-2.c
30 * Tests that we can access gl_TextureMatrix[n] in the vertex shader.
32 * Compared to glsl-vs-texturematrix-1, this uses varying access of the array.
35 #include "piglit-util-gl.h"
37 PIGLIT_GL_TEST_CONFIG_BEGIN
39 config.supports_gl_compat_version = 10;
41 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
43 PIGLIT_GL_TEST_CONFIG_END
45 static GLint prog;
47 enum piglit_result
48 piglit_display(void)
50 GLboolean pass = GL_TRUE;
51 static const float red[] = {1.0, 0.0, 0.0, 1.0};
52 static const float green[] = {0.0, 1.0, 0.0, 1.0};
53 static const float blue[] = {0.0, 0.0, 1.0, 1.0};
54 static const float white[] = {1.0, 1.0, 1.0, 1.0};
55 GLuint tex;
57 glActiveTexture(GL_TEXTURE1);
58 tex = piglit_rgbw_texture(GL_RGBA, 8, 8, GL_FALSE, GL_FALSE, GL_UNSIGNED_NORMALIZED);
59 glEnable(GL_TEXTURE_2D);
61 glMatrixMode(GL_TEXTURE);
62 glLoadIdentity();
63 glRotatef(90, 0, 0, 1);
65 piglit_draw_rect(-1, -1, 2, 2);
67 pass = piglit_probe_pixel_rgba(piglit_width * 1 / 4,
68 piglit_height * 1 / 4,
69 blue) && pass;
70 pass = piglit_probe_pixel_rgba(piglit_width * 3 / 4,
71 piglit_height * 1 / 4,
72 red) && pass;
73 pass = piglit_probe_pixel_rgba(piglit_width * 1 / 4,
74 piglit_height * 3 / 4,
75 white) && pass;
76 pass = piglit_probe_pixel_rgba(piglit_width * 3 / 4,
77 piglit_height * 3 / 4,
78 green) && pass;
80 piglit_present_results();
82 glDeleteTextures(1, &tex);
84 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
87 void piglit_init(int argc, char **argv)
89 GLint vs, fs;
90 int loc;
92 piglit_require_gl_version(20);
94 vs = piglit_compile_shader(GL_VERTEX_SHADER,
95 "shaders/glsl-vs-texturematrix-2.vert");
96 fs = piglit_compile_shader(GL_FRAGMENT_SHADER,
97 "shaders/glsl-tex.frag");
99 prog = piglit_link_simple_program(vs, fs);
101 glUseProgram(prog);
103 loc = glGetUniformLocation(prog, "sampler");
104 glUniform1i(loc, 1);
105 loc = glGetUniformLocation(prog, "i");
106 glUniform1f(loc, 1.0);