ext_transform_feedback: document missing mode in usage
[piglit.git] / tests / general / vbo-bufferdata.c
blob13a79e4fdeb03bd81506ec6ff65e09b624eab6e3
1 /*
2 * Copyright © 2009 Intel Corporation
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
21 * DEALINGS IN THE SOFTWARE.
23 * Authors:
24 * Ben Holmes <shranzel@hotmail.com>
25 * Marek Olšák <maraeo@gmail.com>
28 #include "piglit-util-gl.h"
30 PIGLIT_GL_TEST_CONFIG_BEGIN
32 config.supports_gl_compat_version = 10;
34 config.window_width = 400;
35 config.window_height = 300;
36 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
37 config.khr_no_error_support = PIGLIT_NO_ERRORS;
39 PIGLIT_GL_TEST_CONFIG_END
41 static GLuint vbo;
43 void
44 piglit_init(int argc, char **argv)
46 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
48 piglit_require_extension("GL_ARB_vertex_buffer_object");
50 glGenBuffersARB(1, &vbo);
51 glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
52 glBufferDataARB(GL_ARRAY_BUFFER_ARB, 12 * sizeof(GLfloat),
53 NULL, GL_DYNAMIC_DRAW);
56 enum piglit_result
57 piglit_display(void)
59 GLfloat white[4] = {1.0, 1.0, 1.0, 0.0};
60 GLboolean pass = GL_TRUE;
61 GLfloat varray1[12] = {175, 125, 0,
62 175, 175, 0,
63 125, 125, 0,
64 125, 175, 0};
65 GLfloat varray2[12] = {275, 125, 0,
66 275, 175, 0,
67 225, 125, 0,
68 225, 175, 0};
69 GLenum err;
71 glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
73 glEnableClientState(GL_VERTEX_ARRAY);
74 glVertexPointer(3, GL_FLOAT, 0, 0);
76 glBufferDataARB(GL_ARRAY_BUFFER_ARB, 12 * sizeof(GLfloat),
77 varray1, GL_DYNAMIC_DRAW);
79 glClear(GL_COLOR_BUFFER_BIT);
80 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
82 glBufferDataARB(GL_ARRAY_BUFFER_ARB, 12 * sizeof(GLfloat),
83 varray2, GL_DYNAMIC_DRAW);
85 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
87 if ((err = glGetError()) != 0) {
88 printf("gl error: 0x%08x\n", err);
89 pass = GL_FALSE;
92 pass = pass && piglit_probe_pixel_rgb(250, 150, white);
93 pass = pass && piglit_probe_pixel_rgb(150, 150, white);
95 piglit_present_results();
97 glDisableClientState(GL_VERTEX_ARRAY);
99 return pass ? PIGLIT_PASS : PIGLIT_FAIL;