cmake: move defaults into the per-platform section
[piglit.git] / tests / shaders / glsl-vs-point-size.c
blobab4ab080d1d3b64632743d55a853797b75e4118b
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 * Neil Roberts <neil@linux.intel.com>
28 /** @file glsl-vs-point-size.c
30 * Tests whether a vertex shader can change the point size by writing
31 * to gl_PointSize.
33 * Bug #27250
36 #include "piglit-util-gl.h"
38 PIGLIT_GL_TEST_CONFIG_BEGIN
40 config.supports_gl_compat_version = 10;
42 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
43 config.khr_no_error_support = PIGLIT_NO_ERRORS;
45 PIGLIT_GL_TEST_CONFIG_END
47 static GLint prog;
49 static const float white[4] = {1, 1, 1, 1};
50 static const float black[4] = {0, 0, 0, 0};
52 #define POINT_SIZE 16
54 enum piglit_result
55 piglit_display(void)
57 GLboolean pass = GL_TRUE;
58 float vert[2] = { piglit_width / 2, piglit_height / 2 };
60 /* Clear the window to black */
61 glClear(GL_COLOR_BUFFER_BIT);
63 /* Draw a single white point at the centre of the window. The
64 vertex shader should make this larger */
65 glColor3fv(white);
66 glVertexPointer(2, GL_FLOAT, 0, vert);
67 glEnableClientState(GL_VERTEX_ARRAY);
68 glDrawArrays(GL_POINTS, 0, 1);
69 glDisableClientState(GL_VERTEX_ARRAY);
71 /* Verify that the point is large by looking at some corner pixels */
72 pass &= piglit_probe_pixel_rgb(piglit_width / 2 - POINT_SIZE / 2 + 1,
73 piglit_height / 2 - POINT_SIZE / 2 + 1,
74 white);
75 pass &= piglit_probe_pixel_rgb(piglit_width / 2 + POINT_SIZE / 2 - 1,
76 piglit_height / 2 + POINT_SIZE / 2 - 1,
77 white);
78 /* Sanity check that the corners of the window aren't filled */
79 pass &= piglit_probe_pixel_rgb(0, 0, black);
80 pass &= piglit_probe_pixel_rgb(piglit_width - 1, piglit_height - 1,
81 black);
83 piglit_present_results();
85 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
88 void
89 piglit_init(int argc, char **argv)
91 GLint vs;
92 GLint point_size_range[2];
94 piglit_require_gl_version(20);
95 /* If the driver doesn't claim to support the point size the
96 shader is going to set then we should skip the test */
97 glGetIntegerv(GL_ALIASED_POINT_SIZE_RANGE, point_size_range);
98 if (POINT_SIZE < point_size_range[0] ||
99 POINT_SIZE > point_size_range[1]) {
100 printf("Point size %i not supported\n", POINT_SIZE);
101 piglit_report_result(PIGLIT_SKIP);
104 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
105 glClearColor(0.0, 0.0, 0.0, 1.0);
107 vs = piglit_compile_shader(GL_VERTEX_SHADER,
108 "shaders/glsl-vs-point-size.vert");
110 prog = piglit_link_simple_program(vs, 0);
112 glUseProgram(prog);
114 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);