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