According opengl spec 4.2.pdf table 6.12 (Vertex Array Object State) at page 515: the element buffer object is listed in vertex array object.
Add a testcase to test that. Signed-off-by: Yuanhan Liu <yuanhan....@linux.intel.com> --- tests/all.tests | 1 + tests/general/CMakeLists.gl.txt | 1 + tests/general/vao-element-array-buffer.c | 94 ++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 0 deletions(-) create mode 100644 tests/general/vao-element-array-buffer.c diff --git a/tests/all.tests b/tests/all.tests index 851db11..ad68d71 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -305,6 +305,7 @@ add_plain_test(general, 'two-sided-lighting-separate-specular') add_plain_test(general, 'user-clip') add_plain_test(general, 'vao-01') add_plain_test(general, 'vao-02') +add_plain_test(general, 'vao-element-array-buffer') add_plain_test(general, 'varray-disabled') add_plain_test(general, 'vbo-bufferdata') add_plain_test(general, 'vbo-map-remap') diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt index 58cbaa1..185f59d 100644 --- a/tests/general/CMakeLists.gl.txt +++ b/tests/general/CMakeLists.gl.txt @@ -111,6 +111,7 @@ add_executable (user-clip user-clip.c) add_executable (varray-disabled varray-disabled.c) add_executable (vao-01 vao-01.c) add_executable (vao-02 vao-02.c) +add_executable (vao-element-array-buffer vao-element-array-buffer.c) add_executable (vbo-map-remap vbo-map-remap.c) add_executable (vbo-bufferdata vbo-bufferdata.c) add_executable (vbo-subdata-zero vbo-subdata-zero.c) diff --git a/tests/general/vao-element-array-buffer.c b/tests/general/vao-element-array-buffer.c new file mode 100644 index 0000000..32600b8 --- /dev/null +++ b/tests/general/vao-element-array-buffer.c @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2011 Intel Corporation + * + * 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: + * Yuanhan Liu <yuanhan....@linux.intel.com> + */ + +/** + * @file vao-element-buffer.c + * + * A simple test case to test that GL_ELEMENT_ARRAY_BUFFER is part of vao + * + */ + +#include "piglit-util.h" + +int piglit_width = 100; +int piglit_height = 100; +int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE; + +static GLuint vao; + +enum piglit_result +piglit_display(void) +{ + GLboolean pass = GL_TRUE; + GLfloat expected[4] = {1, 0, 0, 1}; + + glClear(GL_COLOR_BUFFER_BIT); + + glBindVertexArray(vao); + + glColor3f(1, 0, 0); + glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, NULL); + pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, expected); + + glutSwapBuffers(); + + return PIGLIT_PASS; +} + +void +piglit_init(int argc, char **argv) +{ + GLuint vbo; + GLuint element; + GLfloat vertics[] = { + -1, -1, 0, + 1, -1, 0, + 1, 1, 0, + -1, 1, 0, + }; + GLubyte indics[] = {0, 1, 2, 3}; + + piglit_require_extension("GL_ARB_vertex_array_object"); + + glClearColor(0, 0, 0, 1); + + glGenBuffers(1, &vbo); + glGenBuffers(1, &element); + + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + glBindBuffer(GL_ARRAY_BUFFER, vbo); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertics), vertics, GL_STATIC_DRAW); + glVertexPointer(3, GL_FLOAT, 0, NULL); + glEnableClientState(GL_VERTEX_ARRAY); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, element); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indics), indics, GL_STATIC_DRAW); + + glBindVertexArray(0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); +} -- 1.7.4.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev