fix the spelling in whole piglit
[piglit.git] / tests / general / lineloop.c
blob0111267587f8952d517e11e79eccb76a2b18ad31
1 /*
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
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 lineloop.c
27 * Test line loop with many vertices.
28 * No additional lines should appear due to buffer splitting.
31 #include "piglit-util-gl.h"
33 #define WSIZE 400
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;
47 static GLuint dlist;
50 static void
51 draw(GLuint numVerts, float radius)
53 GLuint i;
55 glColor3f(1,0,1);
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);
60 glVertex3f(x, y, 0);
62 glEnd();
65 static void
66 test_prims(void)
68 if (!piglit_automatic)
69 printf("%s: %u vertices\n", TestName, vert_count);
71 glClear(GL_COLOR_BUFFER_BIT);
73 if (use_dlist) {
74 glCallList(dlist);
75 } else {
76 draw(vert_count, 1.0);
78 piglit_present_results();
82 enum piglit_result
83 piglit_display(void)
85 float expected[4] = {0.0f, 0.0f, 0.0f, 0.0f};
86 int pass;
87 int half_quad = (int)((float)(WSIZE/2) / sqrt(2.0f) - 1.0f);
88 test_prims();
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;
96 void
97 piglit_init(int argc, char**argv)
99 int i;
100 for (i = 1; i < argc; ++i) {
101 if (i < argc) {
102 if (strcmp(argv[i], "-count") == 0) {
103 i++;
104 if (i == argc) {
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) {
111 use_dlist = true;
116 glViewport(0,0, WSIZE, WSIZE);
117 glOrtho(-1,1,-1,1,-1,1);
119 if (use_dlist) {
120 dlist = glGenLists(1);
121 glNewList(dlist, GL_COMPILE);
122 draw(vert_count, 1.0);
123 glEndList();