tests/egl_ext_surface_compression: fix incorect executable name
[piglit.git] / tests / egl / egl-nok-texture-from-pixmap.c
blob04cca5c9b45c50051b50d4c563d7151dcdc68a21
1 /*
2 * Copyright © 2010 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 * Author: Kristian Høgsberg <krh@bitplanet.net>
26 /** @file egl-nok-texture-from-pixmap.c
28 * Test EGL_NOK_texture_from_pixmap
31 #include "piglit-util-gl.h"
32 #include "egl-util.h"
34 const char *extensions[] = { "EGL_NOK_texture_from_pixmap", NULL };
36 static const EGLint pixmap_attribs[] = {
37 EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
38 EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
39 EGL_NONE
42 static enum piglit_result
43 draw(struct egl_state *state)
45 EGLSurface *pixmap;
46 EGLint inv;
47 float red[] = { 0.4, 0.0, 0.0, 1.0 };
48 float purple[] = { 0.5, 0.0, 0.5, 1.0 };
49 enum piglit_result result = PIGLIT_PASS;
51 if (!eglGetConfigAttrib(state->egl_dpy, state->cfg,
52 EGL_Y_INVERTED_NOK, &inv)) {
53 fprintf(stderr,
54 "eglGetConfigAttrib(EGL_Y_INVERTED_NOK) failed\n");
55 return PIGLIT_FAIL;
58 printf("EGL_Y_INVERTED_NOK: %s\n", inv ? "TRUE" : "FALSE");
60 pixmap = egl_util_create_pixmap(state, 100, 100, pixmap_attribs);
61 if (!eglMakeCurrent(state->egl_dpy, pixmap, pixmap, state->ctx)) {
62 fprintf(stderr, "eglMakeCurrent() failed\n");
63 piglit_report_result(PIGLIT_FAIL);
66 /* Clear pixmap to purple */
67 glClearColor(0.5, 0.0, 0.5, 1.0);
68 glClear(GL_COLOR_BUFFER_BIT);
70 if (!eglMakeCurrent(state->egl_dpy,
71 state->surf, state->surf, state->ctx)) {
72 fprintf(stderr, "eglMakeCurrent() failed\n");
73 piglit_report_result(PIGLIT_FAIL);
76 glViewport(0, 0, state->width, state->height);
77 piglit_ortho_projection(state->width, state->height, GL_FALSE);
79 glClearColor(0.4, 0.0, 0.0, 1.0);
80 glClear(GL_COLOR_BUFFER_BIT);
82 glEnable(GL_TEXTURE_2D);
83 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
84 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
85 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
87 eglBindTexImage(state->egl_dpy, pixmap, EGL_BACK_BUFFER);
88 piglit_draw_rect_tex(20, 20, 100, 100, 0, 0, 1, 1);
90 if (!piglit_probe_pixel_rgba(10, 10, red) ||
91 !piglit_probe_pixel_rgba(50, 10, red) ||
92 !piglit_probe_pixel_rgba(10, 50, red) ||
93 !piglit_probe_pixel_rgba(50, 50, purple) ||
94 !piglit_probe_pixel_rgba(110, 110, purple) ||
95 !piglit_probe_pixel_rgba(130, 130, red))
96 result = PIGLIT_FAIL;
98 eglSwapBuffers(state->egl_dpy, state->surf);
100 return result;
104 main(int argc, char *argv[])
106 struct egl_test test;
107 const EGLint test_attribs[] =
109 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
110 EGL_NONE
113 egl_init_test(&test);
114 test.extensions = extensions;
115 test.draw = draw;
116 test.config_attribs = test_attribs;
118 if (egl_util_run(&test, argc, argv) != PIGLIT_PASS)
119 return EXIT_FAILURE;
120 return EXIT_SUCCESS;