2 * Copyright (c) 2014 VMware, Inc.
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
27 * Test line loop with many vertices.
28 * No additional lines should appear due to buffer splitting.
31 #include "piglit-util-gl.h"
35 PIGLIT_GL_TEST_CONFIG_BEGIN
37 config
.supports_gl_compat_version
= 10;
38 config
.window_width
= WSIZE
;
39 config
.window_height
= WSIZE
;
40 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
42 PIGLIT_GL_TEST_CONFIG_END
44 static const char *TestName
= "lineloop";
45 static int vert_count
= 10000;
46 static bool use_dlist
= false;
51 draw(GLuint numVerts
, float radius
)
56 glBegin(GL_LINE_LOOP
);
57 for (i
= 0; i
< numVerts
; i
++) {
58 float x
= radius
* sin(i
*M_PI
*2/numVerts
);
59 float y
= radius
* cos(i
*M_PI
*2/numVerts
);
68 if (!piglit_automatic
)
69 printf("%s: %u vertices\n", TestName
, vert_count
);
71 glClear(GL_COLOR_BUFFER_BIT
);
76 draw(vert_count
, 1.0);
78 piglit_present_results();
85 float expected
[4] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
87 int half_quad
= (int)((float)(WSIZE
/2) / sqrt(2.0f
) - 1.0f
);
89 pass
= piglit_probe_rect_rgb(WSIZE
/ 2 - half_quad
,
90 WSIZE
/ 2 - half_quad
,
91 half_quad
, half_quad
, expected
);
92 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
97 piglit_init(int argc
, char**argv
)
100 for (i
= 1; i
< argc
; ++i
) {
102 if (strcmp(argv
[i
], "-count") == 0) {
105 printf("please specify vertex count\n");
106 piglit_report_result(PIGLIT_FAIL
);
108 vert_count
= strtoul(argv
[i
], NULL
, 0);
110 else if (strcmp(argv
[i
], "-dlist") == 0) {
116 glViewport(0,0, WSIZE
, WSIZE
);
117 glOrtho(-1,1,-1,1,-1,1);
120 dlist
= glGenLists(1);
121 glNewList(dlist
, GL_COMPILE
);
122 draw(vert_count
, 1.0);