2 * Copyright © 2014 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
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
23 * Author: Juha-Pekka Heikkilä <juhapekka.heikkila@gmail.com>
26 /** @file egl-create-pbuffer-surface.c
28 * Test EGLCreatePBufferSurface behaviour.
31 #include "piglit-util-gl.h"
34 static enum piglit_result
35 draw(struct egl_state
*state
)
38 const float purple
[] = {1.0, 0.0, 1.0, 1.0};
40 const EGLint srfPbufferAttr
[] =
44 EGL_TEXTURE_FORMAT
, EGL_TEXTURE_RGBA
,
45 EGL_TEXTURE_TARGET
, EGL_TEXTURE_2D
,
46 EGL_LARGEST_PBUFFER
, EGL_TRUE
,
50 surf
= eglCreatePbufferSurface(state
->egl_dpy
, state
->cfg
,
53 if (eglGetError() != EGL_SUCCESS
|| surf
== EGL_NO_SURFACE
) {
54 fprintf(stderr
, "eglCreatePbufferSurface failed\n");
55 piglit_report_result(PIGLIT_FAIL
);
58 glEnable(GL_TEXTURE_2D
);
60 eglMakeCurrent(state
->egl_dpy
, state
->surf
, state
->surf
, state
->ctx
);
61 glClearColor(1.0, 1.0, 1.0, 0.0);
62 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
64 eglBindTexImage(state
->egl_dpy
, surf
, EGL_BACK_BUFFER
);
65 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
66 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
68 glViewport(0, 0, state
->width
, state
->height
);
69 piglit_ortho_projection(state
->width
, state
->height
, GL_FALSE
);
71 eglMakeCurrent(state
->egl_dpy
, surf
, surf
, state
->ctx
);
72 glClearColor(purple
[0], purple
[1], purple
[2], purple
[3]);
73 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
75 eglMakeCurrent(state
->egl_dpy
, state
->surf
, state
->surf
, state
->ctx
);
76 piglit_draw_rect_tex(0, 0, 256, 256, 0, 0, 1, 1);
78 if (!piglit_probe_rect_rgba(0, 0, 256, 256, purple
))
79 piglit_report_result(PIGLIT_FAIL
);
81 piglit_report_result(PIGLIT_PASS
);
85 main(int argc
, char *argv
[])
88 const EGLint test_attribs
[] =
90 EGL_RENDERABLE_TYPE
, EGL_OPENGL_ES_BIT
,
96 test
.stop_on_failure
= true;
97 test
.config_attribs
= test_attribs
;
99 if (egl_util_run(&test
, argc
, argv
) != PIGLIT_PASS
)