arb_copy_image: test copying of different mipmap levels of a texture
[piglit.git] / tests / egl / egl-nok-swap-region.c
blob6512b6b807ec884334d31614b829983fe245179e
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-swap-region.c
28 * Test EGL_NOK_swap_region.
31 #define PFNEGLSWAPBUFFERSREGIONNOK PFNEGLSWAPBUFFERSREGIONNOKPROC
32 #include "piglit-util-gl.h"
33 #include "egl-util.h"
35 const char *extensions[] = { "EGL_NOK_swap_region", NULL };
37 static enum piglit_result
38 draw(struct egl_state *state)
40 EGLint rects[] = {
41 10, 10, 10, 10,
42 20, 20, 20, 10, /* wide rect */
43 40, 30, 10, 20, /* tall rect */
44 50, 50, 10, 10
46 float green[] = { 0.0, 1.0, 0.0, 1.0};
47 float red[] = { 1.0, 0.0, 0.0, 1.0};
48 struct {
49 int x, y;
50 const float *expected;
51 } probes[] = {
52 { 15, 15, red },
53 { 15, state->height - 15, green },
55 { 25, 25, red },
56 { 35, 25, red },
57 { 25, 35, green },
58 { 25, state->height - 25, green },
60 { 45, 35, red },
61 { 45, 45, red },
62 { 55, 35, green },
63 { 45, state->height - 35, green },
65 { 55, 55, red },
66 { 55, state->height - 55, green },
68 PFNEGLSWAPBUFFERSREGIONNOKPROC swap_buffers_region;
69 int i;
71 swap_buffers_region = (PFNEGLSWAPBUFFERSREGIONNOKPROC)
72 eglGetProcAddress("eglSwapBuffersRegionNOK");
74 if (swap_buffers_region == NULL) {
75 fprintf(stderr, "could not getproc eglSwapBuffersRegionNOK");
76 piglit_report_result(PIGLIT_PASS);
79 /* Clear background to green */
80 glClearColor(0.0, 1.0, 0.0, 1.0);
81 glClear(GL_COLOR_BUFFER_BIT);
82 eglSwapBuffers(state->egl_dpy, state->surf);
83 glClearColor(1.0, 0.0, 0.0, 1.0);
84 glClear(GL_COLOR_BUFFER_BIT);
85 swap_buffers_region(state->egl_dpy, state->surf, 4, rects);
87 glFinish();
89 for (i = 0; i < ARRAY_SIZE(probes); i++)
90 if (!egl_probe_front_pixel_rgb(state,
91 probes[i].x,
92 probes[i].y,
93 probes[i].expected))
94 return PIGLIT_FAIL;
96 return PIGLIT_PASS;
99 int
100 main(int argc, char *argv[])
102 struct egl_test test;
104 egl_init_test(&test);
105 test.extensions = extensions;
106 test.draw = draw;
108 if (egl_util_run(&test, argc, argv) != PIGLIT_PASS)
109 return EXIT_FAILURE;
110 return EXIT_SUCCESS;