cl: Don't use device_infos if num_device_infos == 0
[piglit.git] / tests / general / oes-read-format.c
blobcfe6e27c1738c60c814f3777587e2d938b2097a6
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 DEALINGS
21 * IN THE SOFTWARE.
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
28 /** @file oes-read-format.c
30 * Tests that GL_OES_read_format works and returns a set of parameters valid
31 * for ReadPixels.
34 #include "piglit-util-gl.h"
36 PIGLIT_GL_TEST_CONFIG_BEGIN
38 config.supports_gl_compat_version = 10;
40 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
42 PIGLIT_GL_TEST_CONFIG_END
44 enum piglit_result
45 piglit_display(void)
47 GLboolean pass = GL_TRUE;
48 static float green[] = {0.0, 1.0, 0.0, 0.0};
49 uint32_t vals[4];
50 GLint format, type;
52 glColor4fv(green);
53 piglit_draw_rect(0, 0, piglit_width, piglit_height);
55 glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, &format);
56 glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, &type);
58 glReadPixels(1, 1, 1, 1, format, type, vals);
60 pass = glGetError() == 0;
62 piglit_present_results();
64 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
68 static void reshape(int width, int height)
70 piglit_width = width;
71 piglit_height = height;
73 piglit_ortho_projection(width, height, GL_FALSE);
76 void
77 piglit_init(int argc, char **argv)
79 reshape(piglit_width, piglit_height);
80 piglit_require_extension("GL_OES_read_format");