draw-vertices.c 17.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
/*
 * Copyright © 2010 Marek Olšák <maraeo@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 * Authors:
 *    Marek Olšák <maraeo@gmail.com>
 */

/* The test for some tricky bits of the OpenGL vertex submission.
 * The emphasis is taken on non-dword-aligned strides and offsets,
 * but tests for various vertex formats are provided too.
 */

#include "piglit-util.h"

int piglit_width = 320, piglit_height = 60;
int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;

37 38
GLboolean user_va = GL_FALSE;

39 40
void piglit_init(int argc, char **argv)
{
41 42 43 44 45 46 47 48 49
    unsigned i;

    for (i = 1; i < argc; i++) {
        if (!strcmp(argv[i], "user")) {
            user_va = GL_TRUE;
            puts("Testing user vertex arrays.");
        }
    }

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
    piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

    if (!GLEW_VERSION_1_5) {
        printf("Requires OpenGL 1.5\n");
        piglit_report_result(PIGLIT_SKIP);
    }

    glShadeModel(GL_FLAT);
    glClearColor(0.2, 0.2, 0.2, 1.0);
}

static void test_large_vertex_count(float x1, float y1, float x2, float y2, int index)
{
    unsigned tris = 100000;
    float *v = (float*)malloc(sizeof(float) * 6 * tris);
    unsigned i;

67
    /* A large vertex count for DrawArrays */
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
    for (i = 0; i < tris*6; i += 6) {
        v[i+0] = x1;
        v[i+1] = y1;

        v[i+2] = x1;
        v[i+3] = y2;

        v[i+4] = x2;
        v[i+5] = y1;
    }

    glVertexPointer(2, GL_FLOAT, 0, v);
    glDrawArrays(GL_TRIANGLES, 0, tris*3);

    free(v);
}

static GLuint vboVertexPointer(GLint size, GLenum type, GLsizei stride,
                               const GLvoid *buf, GLsizei bufSize, intptr_t bufOffset)
{
88
    GLuint id;
89 90 91 92
    if (user_va) {
        glVertexPointer(size, type, stride, (char*)buf + bufOffset);
        return 0;
    }
93 94 95 96 97 98 99 100 101 102
    glGenBuffers(1, &id);
    glBindBuffer(GL_ARRAY_BUFFER, id);
    glBufferData(GL_ARRAY_BUFFER, bufSize, buf, GL_STATIC_DRAW);
    glVertexPointer(size, type, stride, (void*)bufOffset);
    return id;
}

static GLuint vboColorPointer(GLint size, GLenum type, GLsizei stride,
                              const GLvoid *buf, GLsizei bufSize, intptr_t bufOffset)
{
103
    GLuint id;
104 105 106 107
    if (user_va) {
        glColorPointer(size, type, stride, (char*)buf + bufOffset);
        return 0;
    }
108 109 110 111 112 113 114
    glGenBuffers(1, &id);
    glBindBuffer(GL_ARRAY_BUFFER, id);
    glBufferData(GL_ARRAY_BUFFER, bufSize, buf, GL_STATIC_DRAW);
    glColorPointer(size, type, stride, (void*)bufOffset);
    return id;
}

115 116 117 118
static GLuint vboVertexColorPointer(GLint vSize, GLenum vType, GLint vStride, intptr_t vOffset,
                                    GLint cSize, GLenum cType, GLint cStride, intptr_t cOffset,
                                    const GLvoid *buf, GLsizei bufSize)
{
119
    GLuint id;
120 121 122 123 124
    if (user_va) {
        glVertexPointer(vSize, vType, vStride, (char*)buf + vOffset);
        glColorPointer(cSize, cType, cStride, (char*)buf + cOffset);
        return 0;
    }
125 126 127 128 129 130 131 132
    glGenBuffers(1, &id);
    glBindBuffer(GL_ARRAY_BUFFER, id);
    glBufferData(GL_ARRAY_BUFFER, bufSize, buf, GL_STATIC_DRAW);
    glVertexPointer(vSize, vType, vStride, (void*)vOffset);
    glColorPointer(cSize, cType, cStride, (void*)cOffset);
    return id;
}

133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
static void test_ubyte_colors(float x1, float y1, float x2, float y2, int index)
{
    float v[] = {
        x1, y1,
        x1, y2,
        x2, y1
    };
    unsigned char c3[] = {
        255, 0, 0,
        255, 0, 0,
        255, 0, 0,
    };
    unsigned char c4[] = {
        255, 0, 0, 0,
        255, 0, 0, 0,
        255, 0, 0, 0,
    };
    unsigned char c3o1[] = {
        0,
        255, 0, 0,
        255, 0, 0,
        255, 0, 0,
    };
    unsigned char c4o1[] = {
        0,
        255, 0, 0, 0,
        255, 0, 0, 0,
        255, 0, 0, 0,
    };
    unsigned char c3o2[] = {
        0, 0,
        255, 0, 0,
        255, 0, 0,
        255, 0, 0,
    };
    unsigned char c4o2[] = {
        0, 0,
        255, 0, 0, 0,
        255, 0, 0, 0,
        255, 0, 0, 0,
    };
    unsigned char c3o3[] = {
        0, 0, 0,
        255, 0, 0,
        255, 0, 0,
        255, 0, 0,
    };
    unsigned char c4o3[] = {
        0, 0, 0,
        255, 0, 0, 0,
        255, 0, 0, 0,
        255, 0, 0, 0,
    };
    GLuint vbo;

    glVertexPointer(2, GL_FLOAT, 0, v);

    glEnableClientState(GL_COLOR_ARRAY);
    switch (index) {
        case 0: vbo = vboColorPointer(3, GL_UNSIGNED_BYTE, 3, c3, sizeof(c3), 0); break;
        case 1: vbo = vboColorPointer(3, GL_UNSIGNED_BYTE, 4, c4, sizeof(c4), 0); break;
        case 2: vbo = vboColorPointer(4, GL_UNSIGNED_BYTE, 4, c4, sizeof(c4), 0); break;

        case 3: vbo = vboColorPointer(3, GL_UNSIGNED_BYTE, 3, c3o1, sizeof(c3o1), 1); break;
        case 4: vbo = vboColorPointer(3, GL_UNSIGNED_BYTE, 4, c4o1, sizeof(c4o1), 1); break;
        case 5: vbo = vboColorPointer(4, GL_UNSIGNED_BYTE, 4, c4o1, sizeof(c4o1), 1); break;

        case 6: vbo = vboColorPointer(3, GL_UNSIGNED_BYTE, 3, c3o2, sizeof(c3o2), 2); break;
        case 7: vbo = vboColorPointer(3, GL_UNSIGNED_BYTE, 4, c4o2, sizeof(c4o2), 2); break;
        case 8: vbo = vboColorPointer(4, GL_UNSIGNED_BYTE, 4, c4o2, sizeof(c4o2), 2); break;

        case 9: vbo = vboColorPointer(3, GL_UNSIGNED_BYTE, 3, c3o3, sizeof(c3o3), 3); break;
        case 10:vbo = vboColorPointer(3, GL_UNSIGNED_BYTE, 4, c4o3, sizeof(c4o3), 3); break;
        case 11:vbo = vboColorPointer(4, GL_UNSIGNED_BYTE, 4, c4o3, sizeof(c4o3), 3); break;
    }

    glDrawArrays(GL_TRIANGLES, 0, 3);

    glDisableClientState(GL_COLOR_ARRAY);
212 213
    if (vbo)
        glDeleteBuffers(1, &vbo);
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
}

static void test_short_vertices(float x1, float y1, float x2, float y2, int index)
{
    short v2[] = {
        x1, y1,
        x1, y2,
        x2, y1
    };
    short v3[] = {
        x1, y1, 0,
        x1, y2, 0,
        x2, y1, 0
    };
    short v4[] = {
        x1, y1, 0, 1,
        x1, y2, 0, 1,
        x2, y1, 0, 1
    };
    short v2o[] = {
        0,
        x1, y1,
        x1, y2,
        x2, y1
    };
    short v3o[] = {
        0,
        x1, y1, 0,
        x1, y2, 0,
        x2, y1, 0
    };
    short v4o[] = {
        0,
        x1, y1, 0, 1,
        x1, y2, 0, 1,
        x2, y1, 0, 1
    };
    GLuint vbo;

    switch (index) {
        case 0: vbo = vboVertexPointer(2, GL_SHORT, 4, v2, sizeof(v2), 0); break;

        case 1: vbo = vboVertexPointer(2, GL_SHORT, 6, v3, sizeof(v3), 0); break;
        case 2: vbo = vboVertexPointer(3, GL_SHORT, 6, v3, sizeof(v3), 0); break;

        case 3: vbo = vboVertexPointer(2, GL_SHORT, 8, v4, sizeof(v4), 0); break;
        case 4: vbo = vboVertexPointer(3, GL_SHORT, 8, v4, sizeof(v4), 0); break;
        case 5: vbo = vboVertexPointer(4, GL_SHORT, 8, v4, sizeof(v4), 0); break;

        case 6: vbo = vboVertexPointer(2, GL_SHORT, 4, v2o, sizeof(v2o), 2); break;

        case 7: vbo = vboVertexPointer(2, GL_SHORT, 6, v3o, sizeof(v3o), 2); break;
        case 8: vbo = vboVertexPointer(3, GL_SHORT, 6, v3o, sizeof(v3o), 2); break;

        case 9: vbo = vboVertexPointer(2, GL_SHORT, 8, v4o, sizeof(v4o), 2); break;
        case 10:vbo = vboVertexPointer(3, GL_SHORT, 8, v4o, sizeof(v4o), 2); break;
        case 11:vbo = vboVertexPointer(4, GL_SHORT, 8, v4o, sizeof(v4o), 2); break;
    }

    glDrawArrays(GL_TRIANGLES, 0, 3);

275 276
    if (vbo)
        glDeleteBuffers(1, &vbo);
277 278 279 280
}

static void test_int_vertices(float x1, float y1, float x2, float y2, int index)
{
281
    int v2[] = {
282 283 284 285
        x1, y1,
        x1, y2,
        x2, y1
    };
286 287 288 289 290 291 292 293 294 295 296 297
    int v3[] = {
        x1, y1, 0,
        x1, y2, 0,
        x2, y1, 0
    };
    int v4[] = {
        x1, y1, 0, 1,
        x1, y2, 0, 1,
        x2, y1, 0, 1
    };
    int v2o[] = {
	0,
298 299 300 301
        x1, y1,
        x1, y2,
        x2, y1
    };
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
    int v3o[] = {
	0,
        x1, y1, 0,
        x1, y2, 0,
        x2, y1, 0
    };
    int v4o[] = {
	0,
        x1, y1, 0, 1,
        x1, y2, 0, 1,
        x2, y1, 0, 1
    };
    GLuint vbo;

    switch (index) {
        case 0: vbo = vboVertexPointer(2, GL_INT, 8, v2, sizeof(v2), 0); break;
        case 1: vbo = vboVertexPointer(3, GL_INT, 12, v3, sizeof(v3), 0); break;
        case 2: vbo = vboVertexPointer(4, GL_INT, 16, v4, sizeof(v4), 0); break;
        case 3: vbo = vboVertexPointer(2, GL_INT, 8, v2o, sizeof(v2o), 4); break;
        case 4: vbo = vboVertexPointer(3, GL_INT, 12, v3o, sizeof(v3o), 4); break;
        case 5: vbo = vboVertexPointer(4, GL_INT, 16, v4o, sizeof(v4o), 4); break;
    }
324 325

    glDrawArrays(GL_TRIANGLES, 0, 3);
326

327 328
    if (vbo)
        glDeleteBuffers(1, &vbo);
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
}

static void test_double_vertices(float x1, float y1, float x2, float y2, int index)
{
	double v2[] = {
	    x1, y1,
	    x1, y2,
	    x2, y1
	};
	double v3[] = {
	    x1, y1, 0,
	    x1, y2, 0,
	    x2, y1, 0
	};
	double v4[] = {
	    x1, y1, 0, 1,
	    x1, y2, 0, 1,
	    x2, y1, 0, 1
	};
	double v2o[] = {
	    0,
	    x1, y1,
	    x1, y2,
	    x2, y1
	};
	double v3o[] = {
	    0,
	    x1, y1, 0,
	    x1, y2, 0,
	    x2, y1, 0
	};
	double v4o[] = {
	    0,
	    x1, y1, 0, 1,
	    x1, y2, 0, 1,
	    x2, y1, 0, 1
	};
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
	double v2s[] = {
	    0,  0,
	    x1, y1,
	    x1, y2,
	    x2, y1
	};
	double v3s[] = {
	    0,  0,  0,
	    x1, y1, 0,
	    x1, y2, 0,
	    x2, y1, 0
	};
	double v4s[] = {
	    0,  0,  0, 0,
	    x1, y1, 0, 1,
	    x1, y2, 0, 1,
	    x2, y1, 0, 1
	};
384 385 386
	GLuint vbo;

	switch (index) {
387 388 389 390 391 392 393 394 395
	case 0: vbo = vboVertexPointer(2, GL_DOUBLE, 16, v2, sizeof(v2), 0); break;
	case 1: vbo = vboVertexPointer(3, GL_DOUBLE, 24, v3, sizeof(v3), 0); break;
	case 2: vbo = vboVertexPointer(4, GL_DOUBLE, 32, v4, sizeof(v4), 0); break;
	case 3: vbo = vboVertexPointer(2, GL_DOUBLE, 16, v2o, sizeof(v2o), 8); break;
	case 4: vbo = vboVertexPointer(3, GL_DOUBLE, 24, v3o, sizeof(v3o), 8); break;
	case 5: vbo = vboVertexPointer(4, GL_DOUBLE, 32, v4o, sizeof(v4o), 8); break;
	case 6: vbo = vboVertexPointer(2, GL_DOUBLE, 16, v2s, sizeof(v2s), 0); break;
	case 7: vbo = vboVertexPointer(3, GL_DOUBLE, 24, v3s, sizeof(v3s), 0); break;
	case 8: vbo = vboVertexPointer(4, GL_DOUBLE, 32, v4s, sizeof(v4s), 0); break;
396 397
	}

398 399 400 401
	if (index <= 5)
		glDrawArrays(GL_TRIANGLES, 0, 3);
	else
		glDrawArrays(GL_TRIANGLES, 1, 3);
402

403 404
	if (vbo)
	    glDeleteBuffers(1, &vbo);
405 406
}

407 408 409 410 411 412 413 414 415 416 417 418 419 420
static void test_interleaved_vertices(float x1, float y1, float x2, float y2, int index)
{
    static const unsigned int offset[] = {4, 5, 6, 8};

    struct vertex {
        GLshort v[2];
        GLubyte c[8];
    } v[] = {
        {{x1, y1}, {0}},
        {{x1, y2}, {0}},
        {{x2, y1}, {0}}
    };

    unsigned int i;
421 422 423
    GLuint vbo;

    /* Set color green */
424 425 426 427
    for (i = 0; i < 3; ++i)
        v[i].c[offset[index] - 3] = 0xff;

    glEnableClientState(GL_COLOR_ARRAY);
428 429 430
    vbo = vboVertexColorPointer(2, GL_SHORT, sizeof(struct vertex), 0,
                                3, GL_UNSIGNED_BYTE, sizeof(struct vertex), offset[index],
                                v, sizeof(v));
431 432 433 434

    glDrawArrays(GL_TRIANGLES, 0, 3);

    glDisableClientState(GL_COLOR_ARRAY);
435 436
    if (vbo)
        glDeleteBuffers(1, &vbo);
437 438
}

439 440
static void test_mixed_user_and_vbo_buffers(float x1, float y1, float x2, float y2, int index)
{
441 442 443 444
    float v3[] = {
        x1, y1, 0,
        x1, y2, 0,
        x2, y1, 0
445 446 447 448 449 450 451 452 453 454 455 456
    };
    float c3[] = {
        0, 0, 1,
        0, 0, 1,
        0, 0, 1
    };
    GLuint vbo;

    glEnableClientState(GL_COLOR_ARRAY);

    if (!index) {
        glColorPointer(3, GL_FLOAT, 0, c3);
457
        vbo = vboVertexPointer(3, GL_FLOAT, 0, v3, sizeof(v3), 0);
458
    } else {
459
        glVertexPointer(3, GL_FLOAT, 0, v3);
460 461 462 463 464 465
        vbo = vboColorPointer(3, GL_FLOAT, 0, c3, sizeof(c3), 0);
    }

    glDrawArrays(GL_TRIANGLES, 0, 3);

    glDisableClientState(GL_COLOR_ARRAY);
466 467
    if (vbo)
        glDeleteBuffers(1, &vbo);
468 469
}

470 471 472 473 474
enum {
    BOTH,
    USER
};

475 476 477 478
struct test {
    void (*test)(float x1, float y1, float x2, float y2, int index);
    int index;
    float expected_color[3];
479
    int flag;
480 481 482 483
    const char *name;
};

struct test tests[] = {
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
    {test_ubyte_colors, 0, {1, 0, 0}, BOTH, "Ubyte colors - components: 3, stride: 3,"},
    {test_ubyte_colors, 1, {1, 0, 0}, BOTH, "Ubyte colors - components: 3, stride: 4,"},
    {test_ubyte_colors, 2, {1, 0, 0}, BOTH, "Ubyte colors - components: 4, stride: 4,"},
    {test_ubyte_colors, 3, {1, 0, 0}, BOTH, "Ubyte colors - components: 3, stride: 3, offset: 1"},
    {test_ubyte_colors, 4, {1, 0, 0}, BOTH, "Ubyte colors - components: 3, stride: 4, offset: 1"},
    {test_ubyte_colors, 5, {1, 0, 0}, BOTH, "Ubyte colors - components: 4, stride: 4, offset: 1"},
    {test_ubyte_colors, 6, {1, 0, 0}, BOTH, "Ubyte colors - components: 3, stride: 3, offset: 2"},
    {test_ubyte_colors, 7, {1, 0, 0}, BOTH, "Ubyte colors - components: 3, stride: 4, offset: 2"},
    {test_ubyte_colors, 8, {1, 0, 0}, BOTH, "Ubyte colors - components: 4, stride: 4, offset: 2"},
    {test_ubyte_colors, 9, {1, 0, 0}, BOTH, "Ubyte colors - components: 3, stride: 3, offset: 3"},
    {test_ubyte_colors, 10, {1, 0, 0}, BOTH, "Ubyte colors - components: 3, stride: 4, offset: 3"},
    {test_ubyte_colors, 11, {1, 0, 0}, BOTH, "Ubyte colors - components: 4, stride: 4, offset: 3"},

    {test_short_vertices, 0, {1, 1, 1}, BOTH, "Short vertices - components: 2, stride: 4,"},
    {test_short_vertices, 1, {1, 1, 1}, BOTH, "Short vertices - components: 2, stride: 6,"},
    {test_short_vertices, 2, {1, 1, 1}, BOTH, "Short vertices - components: 3, stride: 6,"},
    {test_short_vertices, 3, {1, 1, 1}, BOTH, "Short vertices - components: 2, stride: 8,"},
    {test_short_vertices, 4, {1, 1, 1}, BOTH, "Short vertices - components: 3, stride: 8,"},
    {test_short_vertices, 5, {1, 1, 1}, BOTH, "Short vertices - components: 4, stride: 8,"},
    {test_short_vertices, 6, {1, 1, 1}, BOTH, "Short vertices - components: 2, stride: 4, offset: 2"},
    {test_short_vertices, 7, {1, 1, 1}, BOTH, "Short vertices - components: 2, stride: 6, offset: 2"},
    {test_short_vertices, 8, {1, 1, 1}, BOTH, "Short vertices - components: 3, stride: 6, offset: 2"},
    {test_short_vertices, 9, {1, 1, 1}, BOTH, "Short vertices - components: 2, stride: 8, offset: 2"},
    {test_short_vertices, 10, {1, 1, 1}, BOTH, "Short vertices - components: 3, stride: 8, offset: 2"},
    {test_short_vertices, 11, {1, 1, 1}, BOTH, "Short vertices - components: 4, stride: 8, offset: 2"},

    {test_int_vertices, 0, {1, 1, 1}, BOTH, "Int vertices - components: 2, stride: 8"},
    {test_int_vertices, 1, {1, 1, 1}, BOTH, "Int vertices - components: 3, stride: 12"},
    {test_int_vertices, 2, {1, 1, 1}, BOTH, "Int vertices - components: 4, stride: 16"},
    {test_int_vertices, 3, {1, 1, 1}, BOTH, "Int vertices - components: 2, stride: 8,  offset: 4"},
    {test_int_vertices, 4, {1, 1, 1}, BOTH, "Int vertices - components: 3, stride: 12, offset: 4"},
    {test_int_vertices, 5, {1, 1, 1}, BOTH, "Int vertices - components: 4, stride: 16, offset: 4"},

    {test_double_vertices, 0, {1, 1, 1}, BOTH, "Double vertices - components: 2, stride: 16"},
    {test_double_vertices, 1, {1, 1, 1}, BOTH, "Double vertices - components: 3, stride: 24"},
    {test_double_vertices, 2, {1, 1, 1}, BOTH, "Double vertices - components: 4, stride: 32"},
    {test_double_vertices, 3, {1, 1, 1}, BOTH, "Double vertices - components: 2, stride: 16, offset: 8"},
    {test_double_vertices, 4, {1, 1, 1}, BOTH, "Double vertices - components: 3, stride: 24, offset: 8"},
    {test_double_vertices, 5, {1, 1, 1}, BOTH, "Double vertices - components: 4, stride: 32, offset: 8"},
    {test_double_vertices, 6, {1, 1, 1}, BOTH, "Double vertices - components: 2, stride: 16, start: 1"},
    {test_double_vertices, 7, {1, 1, 1}, BOTH, "Double vertices - components: 3, stride: 24, start: 1"},
    {test_double_vertices, 8, {1, 1, 1}, BOTH, "Double vertices - components: 4, stride: 32, start: 1"},

    {test_interleaved_vertices, 0, {0, 1, 0}, BOTH, "Interleaved VBO - gap: 0"},
    {test_interleaved_vertices, 1, {0, 1, 0}, BOTH, "Interleaved VBO - gap: 1"},
    {test_interleaved_vertices, 2, {0, 1, 0}, BOTH, "Interleaved VBO - gap: 2"},
    {test_interleaved_vertices, 3, {0, 1, 0}, BOTH, "Interleaved VBO - gap: 4"},

    {test_mixed_user_and_vbo_buffers, 0, {0, 0, 1}, BOTH, "Mixed buffers - 0: vbo,  1: user"},
    {test_mixed_user_and_vbo_buffers, 1, {0, 0, 1}, BOTH, "Mixed buffers - 0: user, 1: vbo"},

    {test_large_vertex_count, 0, {1, 1, 1}, USER, "Large vertex count"},
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550

    {0}
};

enum piglit_result
piglit_display(void)
{
    GLboolean pass = GL_TRUE;
    unsigned i;
    float x = 0, y = 0;

    glClear(GL_COLOR_BUFFER_BIT);
    glEnableClientState(GL_VERTEX_ARRAY);

    for (i = 0; tests[i].test; i++) {
551 552 553
        if (!user_va && tests[i].flag == USER)
            continue;

554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
        glBindBuffer(GL_ARRAY_BUFFER, 0);

        printf("%s\n", tests[i].name);
        tests[i].test(x, y, x+20, y+20, tests[i].index);
        assert(glGetError() == 0);
        pass = piglit_probe_pixel_rgb(x+5, y+5, tests[i].expected_color) && pass;

        x += 20;
        if (x > 300) {
            x = 0;
            y += 20;
        }
    }

    glFinish();
    glutSwapBuffers();

571
    return pass ? PIGLIT_PASS : PIGLIT_FAIL;
572
}