fbo-mrt-alphatest: Actually require MRTs to be available.
[piglit.git] / tests / general / vbo-subdata-sync.c
blob949279955c092e943867dd094b94eabf5ab272f3
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 * Eric Anholt <eric@anholt.net>
28 /** @file vbo-subdata-sync
30 * Test for synchronizing behavior of glBufferSubDataARB, bug #23857.
33 #include "piglit-util-gl.h"
35 PIGLIT_GL_TEST_CONFIG_BEGIN
37 config.supports_gl_compat_version = 10;
39 config.window_width = 400;
40 config.window_height = 300;
41 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
42 config.khr_no_error_support = PIGLIT_NO_ERRORS;
44 PIGLIT_GL_TEST_CONFIG_END
46 static GLuint vbo;
48 void
49 piglit_init(int argc, char **argv)
51 piglit_require_extension("GL_ARB_vertex_buffer_object");
53 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
55 glGenBuffersARB(1, &vbo);
56 glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
59 enum piglit_result
60 piglit_display(void)
62 GLfloat white[4] = {1.0, 1.0, 1.0, 0.0};
63 GLboolean pass = GL_TRUE;
64 GLfloat varray1[12] = {175, 125, 0,
65 175, 175, 0,
66 125, 125, 0,
67 125, 175, 0};
68 GLfloat varray2[12] = {275, 125, 0,
69 275, 175, 0,
70 225, 125, 0,
71 225, 175, 0};
72 GLenum err;
74 glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
76 glEnableClientState(GL_VERTEX_ARRAY);
77 glVertexPointer(3, GL_FLOAT, 0, 0);
79 glBufferDataARB(GL_ARRAY_BUFFER_ARB, 12 * sizeof(GLfloat),
80 varray1, GL_DYNAMIC_DRAW);
82 glClear(GL_COLOR_BUFFER_BIT);
83 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
85 glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 12 * sizeof(GLfloat),
86 varray2);
88 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
90 if ((err = glGetError()) != 0) {
91 printf("gl error: 0x%08x\n", err);
92 pass = GL_FALSE;
95 pass = pass && piglit_probe_pixel_rgb(250, 150, white);
96 pass = pass && piglit_probe_pixel_rgb(150, 150, white);
98 piglit_present_results();
100 glDisableClientState(GL_VERTEX_ARRAY);
102 return pass ? PIGLIT_PASS : PIGLIT_FAIL;