cmake: move defaults into the per-platform section
[piglit.git] / tests / shaders / vp-clipdistance-03.c
blob26c3275c50f327bdc210c6076c66d662fe853558
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-clipdistance-03.c
26 * Validate that writes to Y, Z, and W of result.clip has no effect.
28 * \author Ian Romanick <ian.d.romanick@intel.com>
31 #include "piglit-util-gl.h"
33 #define TEST_ROWS 1
34 #define TEST_COLS 1
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 "MOV result.clip[0], vertex.texcoord[0].yxxx;\n"
51 PIGLIT_VERTEX_PROGRAM_MVP_TRANSFORM
52 "END\n"
55 static const char fragment_source[] =
56 "!!ARBfp1.0\n"
57 "MOV result.color, {0.0, 1.0, 0.0, 1.0};\n"
58 "END"
61 /**
62 * \name Handles to programs.
64 /*@{*/
65 static GLint progs[TEST_COLS];
66 static GLint frag_prog;
67 /*@}*/
70 static const GLfloat clear_color[4] = { 0.5, 0.5, 0.5, 1.0 };
73 enum piglit_result
74 piglit_display(void)
76 static const GLfloat color[4] = { 0.0, 1.0, 0.0, 1.0 };
77 enum piglit_result result = PIGLIT_PASS;
78 unsigned i;
80 glClear(GL_COLOR_BUFFER_BIT);
82 for (i = 0; i < ARRAY_SIZE(progs); i++) {
83 const int x = 1 + (i * (BOX_SIZE + 1));
85 glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);
86 glEnable(GL_CLIP_PLANE0 + i);
87 piglit_draw_rect_tex(x, 1, BOX_SIZE, BOX_SIZE,
88 1.0, 1.0, -2.0, 0.0);
89 glDisable(GL_CLIP_PLANE0 + i);
91 if (!piglit_probe_pixel_rgb(x + (BOX_SIZE / 2),
92 1 + (BOX_SIZE / 2),
93 color)) {
94 result = PIGLIT_FAIL;
98 piglit_present_results();
99 return result;
103 void
104 piglit_init(int argc, char **argv)
106 unsigned i;
108 (void) argc;
109 (void) argv;
111 piglit_require_vertex_program();
112 piglit_require_fragment_program();
113 piglit_require_extension("GL_NV_vertex_program2_option");
114 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
116 for (i = 0; i < ARRAY_SIZE(progs); i++) {
117 char shader_source[1024];
119 snprintf(shader_source, sizeof(shader_source),
120 vertex_source_template);
122 progs[i] = piglit_compile_program(GL_VERTEX_PROGRAM_ARB,
123 shader_source);
126 glEnable(GL_FRAGMENT_PROGRAM_ARB);
127 glEnable(GL_VERTEX_PROGRAM_ARB);
129 frag_prog = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB,
130 fragment_source);
131 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, frag_prog);
133 glClearColor(clear_color[0],
134 clear_color[1],
135 clear_color[2],
136 clear_color[3]);