glx-multithread-texture: Avoid front-buffer rendering.
[piglit.git] / tests / shaders / vp-address-05.c
blob483b8d75b29a5b80bdcbce918c731c1557d80d70
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 DEALINGS
21 * IN THE SOFTWARE.
24 /**
25 * \file vp-address-05.c
26 * Simple test of the ARA instruction from GL_NV_vertex_program2_option.
28 * \author Ian Romanick <ian.d.romanick@intel.com>
31 #include "piglit-util-gl.h"
33 #define TEST_ROWS 1
34 #define TEST_COLS 4
35 #define BOX_SIZE 32
37 PIGLIT_GL_TEST_CONFIG_BEGIN
39 config.supports_gl_compat_version = 10;
41 config.window_width = (((BOX_SIZE+1)*TEST_COLS)+1);
42 config.window_height = (((BOX_SIZE+1)*TEST_ROWS)+1);
43 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
45 PIGLIT_GL_TEST_CONFIG_END
47 static const char vertex_source_template[] =
48 "!!ARBvp1.0\n"
49 "OPTION NV_vertex_program2;\n"
50 "PARAM colors[] = { program.env[0..3] };\n"
51 "ADDRESS A0;\n"
52 "\n"
53 "ARL A0, vertex.attrib[1];\n"
54 "ARA A0.xy, A0;\n"
55 "MOV result.color, colors[A0.%c];\n"
56 PIGLIT_VERTEX_PROGRAM_MVP_TRANSFORM
57 "END\n"
61 /**
62 * \name Handles to programs.
64 /*@{*/
65 static GLint progs[TEST_COLS];
66 /*@}*/
69 enum piglit_result
70 piglit_display(void)
72 static const GLfloat color[4] = { 0.0, 1.0, 0.0, 1.0 };
73 static const GLfloat bad_color[4] = { 1.0, 0.0, 0.0, 1.0 };
74 static const GLfloat attrib[4][4] = {
75 { 1.0, -37.0, 1.0, 68.2 },
76 { -37.0, 1.0, 68.2, 1.0 },
77 { 0.0, 3.0, 2.0, 1.0 },
78 { 0.0, 3.0, 1.0, 2.0 },
80 enum piglit_result result = PIGLIT_PASS;
81 unsigned i;
83 glClear(GL_COLOR_BUFFER_BIT);
85 glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 0, bad_color);
86 glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 1, bad_color);
87 glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 2, color);
88 glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 3, bad_color);
90 for (i = 0; i < ARRAY_SIZE(progs); i++) {
91 const int x = 1 + (i * (BOX_SIZE + 1));
93 glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);
95 glVertexAttrib4fvARB(1, attrib[i]);
97 piglit_draw_rect(x, 1, BOX_SIZE, BOX_SIZE);
99 if (!piglit_probe_pixel_rgb(x + (BOX_SIZE / 2),
100 1 + (BOX_SIZE / 2),
101 color)) {
102 result = PIGLIT_FAIL;
106 piglit_present_results();
107 return result;
111 void
112 piglit_init(int argc, char **argv)
114 static const char components[] = "xyzw";
115 unsigned i;
117 (void) argc;
118 (void) argv;
120 piglit_require_vertex_program();
121 piglit_require_extension("GL_NV_vertex_program2_option");
122 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
124 for (i = 0; i < ARRAY_SIZE(progs); i++) {
125 char shader_source[1024];
127 snprintf(shader_source, sizeof(shader_source),
128 vertex_source_template, components[i]);
130 progs[i] = piglit_compile_program(GL_VERTEX_PROGRAM_ARB,
131 shader_source);
134 glEnable(GL_VERTEX_PROGRAM_ARB);
136 glClearColor(0.5, 0.5, 0.5, 1.0);