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
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
24 * Eric Anholt <eric@anholt.net>
28 /** @file glsl-fs-pointcoord.c
30 * Tests that gl_PointCoord produces the expected output in a fragment shader
31 * with point sprites enabled.
41 #include "piglit-util-gl.h"
43 PIGLIT_GL_TEST_CONFIG_BEGIN
45 config
.supports_gl_compat_version
= 10;
47 config
.window_width
= 256;
48 config
.window_height
= 256;
49 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGB
;
51 PIGLIT_GL_TEST_CONFIG_END
54 static GLint point_size
;
59 GLboolean pass
= GL_TRUE
;
60 const float red
[4] = {1, 0, 0, 0};
61 const float green
[4] = {0, 1, 0, 0};
62 const float yellow
[4] = {1, 1, 0, 0};
63 const float black
[4] = {0, 0, 0, 0};
65 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);
67 glClearColor(0.5, 0.5, 0.5, 0.5);
68 glClear(GL_COLOR_BUFFER_BIT
);
70 glPointSize(point_size
);
72 glVertex2f(point_size
/ 2.0, point_size
/ 2.0);
75 pass
= pass
&& piglit_probe_pixel_rgb(0, 0, green
);
76 pass
= pass
&& piglit_probe_pixel_rgb(point_size
- 1, 0, yellow
);
77 pass
= pass
&& piglit_probe_pixel_rgb(0, point_size
- 1, black
);
78 pass
= pass
&& piglit_probe_pixel_rgb(point_size
- 1, point_size
- 1, red
);
80 piglit_present_results();
82 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
85 void piglit_init(int argc
, char**argv
)
88 GLint point_size_limits
[2];
90 piglit_require_gl_version(20);
91 piglit_require_extension("GL_ARB_point_sprite");
93 glGetIntegerv(GL_ALIASED_POINT_SIZE_RANGE
, point_size_limits
);
94 point_size
= point_size_limits
[1];
96 if (point_size
> piglit_width
)
97 point_size
= piglit_width
;
98 if (point_size
> piglit_height
)
99 point_size
= piglit_height
;
101 vs
= piglit_compile_shader(GL_VERTEX_SHADER
,
102 "shaders/glsl-fs-pointcoord.vert");
103 fs
= piglit_compile_shader(GL_FRAGMENT_SHADER
,
104 "shaders/glsl-fs-pointcoord.frag");
106 prog
= piglit_link_simple_program(vs
, fs
);
108 glEnable(GL_POINT_SPRITE
);