README: recommend Ninja by default and switch to cmake --build
[piglit.git] / tests / egl / egl-invalid-attr.c
bloba38a2d51f4ac6dea9a45b003684a21a41febdfec
1 /*
2 * Copyright © 2016 Collabora Ltd.
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.
24 #include "piglit-util-egl.h"
25 #include "piglit-util-gl.h"
27 /**
28 * @file egl-invalid-attr.c
30 * From EGL_KHR_image_base.txt: If an attribute specified in <attrib_list> is
31 * not one of the attributes listed in Table bbb, the error EGL_BAD_PARAMETER
32 * is generated.
35 PIGLIT_GL_TEST_CONFIG_BEGIN
37 config.supports_gl_compat_version = 10;
39 PIGLIT_GL_TEST_CONFIG_END
42 enum piglit_result
43 piglit_display(void)
45 GLuint tex;
46 const unsigned char src[] = { 0x00, 0x00, 0x00, 0x00 };
47 EGLint attr[] = {
48 0xFFFF, 0, //invalid attr
49 EGL_NONE
51 PFNEGLCREATEIMAGEKHRPROC peglCreateImageKHR = NULL;
53 peglCreateImageKHR =
54 (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress ("eglCreateImageKHR");
55 if (!peglCreateImageKHR) {
56 printf ("could not get address for "
57 "eglCreateImageKHR, skipping\n");
58 return PIGLIT_SKIP;
61 glGenTextures(1, &tex);
62 glBindTexture(GL_TEXTURE_2D, tex);
64 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA,
65 GL_UNSIGNED_BYTE, src);
67 peglCreateImageKHR(eglGetCurrentDisplay(),
68 eglGetCurrentContext(),
69 EGL_GL_TEXTURE_2D_KHR,
70 (EGLClientBuffer)(intptr_t)tex,
71 attr);
73 if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) {
74 fprintf(stderr, "eglCreateImageKHR() "
75 "error wasn't EGL_BAD_PARAMETER\n");
76 piglit_report_result(PIGLIT_FAIL);
79 glDeleteTextures(1, &tex);
82 return PIGLIT_PASS;
85 void
86 piglit_init(int argc, char **argv)
88 EGLDisplay dpy;
90 /* this check could be turned into a helper fn*/
91 dpy = eglGetCurrentDisplay();
92 if (!dpy) {
93 printf ("EGL not supported on this platform, skipping\n");
94 piglit_report_result(PIGLIT_SKIP);
97 piglit_require_egl_extension(dpy, "EGL_KHR_image_base");
98 piglit_require_egl_extension(dpy, "EGL_KHR_gl_texture_2D_image");