2 * Copyright © 2022 Collabora Ltd
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 * Erik Faye-Lund <erik.faye-lund@collabora.com>
29 * Test that the coverage of multiple line-segments split at various positions
33 #include "piglit-util-gl.h"
35 PIGLIT_GL_TEST_CONFIG_BEGIN
37 config
.supports_gl_compat_version
= 10;
39 config
.window_width
= 300;
40 config
.window_height
= 100;
41 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
43 PIGLIT_GL_TEST_CONFIG_END
48 glClearColor(0.0, 0.0, 0.0, 0.0);
49 glClear(GL_COLOR_BUFFER_BIT
);
51 glColor4f(0.5, 0.5, 0.5, 1.0);
52 glEnable(GL_LINE_SMOOTH
);
53 /* GL AA lines produce an alpha value */
55 glBlendFunc(GL_SRC_ALPHA
, GL_ONE
);
60 for (y
= 0; y
* 4 < piglit_height
; y
++) {
61 float seg_width
= 0.25 + y
* 0.25;
63 for (x1
= 0; x1
< piglit_width
; x1
+= seg_width
) {
64 float x2
= x1
+ seg_width
;
67 glVertex2f(x1
, 1.5 + y
* 4);
68 glVertex2f(x2
, 1.5 + y
* 4);
73 GLboolean pass
= GL_TRUE
;
74 for (y
= 1; y
< piglit_height
; y
+= 4) {
75 float expected
[4] = { 0.5, 0.5, 0.5, 1.0 };
76 pass
= pass
&& piglit_probe_rect_rgb(0, y
, piglit_width
, 1, expected
);
79 piglit_present_results();
81 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
85 piglit_init(int argc
, char **argv
)
87 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);