diff options
author | Marek Olšák <maraeo@gmail.com> | 2011-09-25 15:40:27 +0200 |
---|---|---|
committer | Marek Olšák <maraeo@gmail.com> | 2011-09-25 17:25:04 +0200 |
commit | c651cfa3aa8f0cbf3aef2b721e7f467bc2e4d164 (patch) | |
tree | 5562a7f396d694f0454e4c0c5e4fcc8b5ad91abc /tests/general/draw-elements-base-vertex.c | |
parent | 67b2d77e158b9bc8c49652183281ecd77630a05b (diff) |
draw-elements-base-vertex: test user vertex arrays
Diffstat (limited to 'tests/general/draw-elements-base-vertex.c')
-rw-r--r-- | tests/general/draw-elements-base-vertex.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/tests/general/draw-elements-base-vertex.c b/tests/general/draw-elements-base-vertex.c index 53fc7d251..f61d86e0e 100644 --- a/tests/general/draw-elements-base-vertex.c +++ b/tests/general/draw-elements-base-vertex.c @@ -37,7 +37,7 @@ int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE; #define NUM_QUADS 10 -static GLuint ib_offset; +static uintptr_t ib_offset; void piglit_init(int argc, char **argv) @@ -45,23 +45,36 @@ piglit_init(int argc, char **argv) GLfloat *vb; GLuint *ib; GLuint vbo; + GLboolean user_va = GL_FALSE; int i; - glewInit(); - piglit_require_extension("GL_ARB_vertex_buffer_object"); + for (i = 1; i < argc; i++) { + if (!strcmp(argv[i], "user_varrays")) { + user_va = GL_TRUE; + puts("Testing user vertex arrays."); + } + } + + if (!user_va) + piglit_require_extension("GL_ARB_vertex_buffer_object"); piglit_require_extension("GL_ARB_draw_elements_base_vertex"); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); - glGenBuffersARB(1, &vbo); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo); - glBufferDataARB(GL_ARRAY_BUFFER_ARB, - NUM_QUADS * 8 * sizeof(GLfloat) + - 2 * 4 * sizeof(GLuint), - NULL, GL_DYNAMIC_DRAW); - vb = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); + if (!user_va) { + glGenBuffersARB(1, &vbo); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, + NUM_QUADS * 8 * sizeof(GLfloat) + + 2 * 4 * sizeof(GLuint), + NULL, GL_DYNAMIC_DRAW); + vb = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); + } else { + vb = malloc(NUM_QUADS * 8 * sizeof(GLfloat) + + 2 * 4 * sizeof(GLuint)); + } for (i = 0; i < NUM_QUADS; i++) { float x1 = 10; @@ -79,12 +92,15 @@ piglit_init(int argc, char **argv) for (i = 0; i < 8; i++) ib[i] = i; - glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); + if (user_va) { + ib_offset = (uintptr_t)ib; + } else { + glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vbo); + } glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, 0); - - glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vbo); + glVertexPointer(2, GL_FLOAT, 0, user_va ? vb : NULL); } enum piglit_result |