diff options
author | Adam Jackson <ajax@redhat.com> | 2011-05-17 13:45:29 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2011-05-17 13:45:29 -0400 |
commit | 16d279c318d03d723c717085edf71acc9ce9c52c (patch) | |
tree | 5bcb19ede3d4907430eca8d782a6c30810c8a761 /tests/glx | |
parent | c9bc190f6589f38093c0aa76df90bab1cf04cf7d (diff) |
glx-copy-sub-buffer: test GLX_MESA_copy_sub_buffer
Diffstat (limited to 'tests/glx')
-rw-r--r-- | tests/glx/CMakeLists.gl.txt | 2 | ||||
-rw-r--r-- | tests/glx/glx-copy-sub-buffer.c | 112 |
2 files changed, 114 insertions, 0 deletions
diff --git a/tests/glx/CMakeLists.gl.txt b/tests/glx/CMakeLists.gl.txt index 74f49aa4..b2fc2b6e 100644 --- a/tests/glx/CMakeLists.gl.txt +++ b/tests/glx/CMakeLists.gl.txt @@ -50,6 +50,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") target_link_libraries(glx-pixmap-crosscheck X11) add_executable (glx-visuals-stencil glx-visuals-stencil.c) + + add_executable (glx-copy-sub-buffer glx-copy-sub-buffer.c) ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") # vim: ft=cmake: diff --git a/tests/glx/glx-copy-sub-buffer.c b/tests/glx/glx-copy-sub-buffer.c new file mode 100644 index 00000000..a25b758a --- /dev/null +++ b/tests/glx/glx-copy-sub-buffer.c @@ -0,0 +1,112 @@ +/* + * Copyright Christopher James Halse Rogers <christopher.halse.rogers at canonical.com> + * Copyright 2010 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Christopher James Halse Rogers <christopher.halse.rogers at canonical.com> + * Adam Jackson <ajax@redhat.com> + * + * Derived from glx-make-current.c + */ + +/** @file glx-copy-sub-buffer.c + * + * Test that GLX_MESA_copy_sub_buffer works as advertised + */ + +#include "piglit-util.h" +#include "piglit-glx-util.h" + +int piglit_width = 100, piglit_height = 100; +static Display *dpy; +static Window win_one; +static XVisualInfo *visinfo; +static PFNGLXCOPYSUBBUFFERMESAPROC CopySubBuffer; + +enum piglit_result +draw(Display *dpy) +{ + GLXContext ctx; + GLboolean pass = GL_TRUE; + static float red[] = {1.0, 0.0, 0.0, 0.0}; + static float green[] = {0.0, 1.0, 0.0, 0.0}; + + ctx = piglit_get_glx_context(dpy, visinfo); + glXMakeCurrent(dpy, win_one, ctx); + + glClearColor(1.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + glXSwapBuffers(dpy, win_one); + + glClearColor(0.0, 1.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + CopySubBuffer(dpy, win_one, + piglit_width / 4, + piglit_height / 4, + piglit_width / 2, + piglit_height / 2); + + glReadBuffer(GL_FRONT); + + pass &= piglit_probe_rect_rgb(0, 0, piglit_width / 4, piglit_height / 4, + red); + pass &= piglit_probe_rect_rgb(piglit_width / 4, piglit_width / 4, + piglit_width / 2, piglit_height / 2, + green); + + glXMakeCurrent(dpy, None, NULL); + glXDestroyContext(dpy, ctx); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +int +main(int argc, char **argv) +{ + int i; + + for(i = 1; i < argc; ++i) { + if (!strcmp(argv[i], "-auto")) + piglit_automatic = 1; + else + fprintf(stderr, "Unknown option: %s\n", argv[i]); + } + + dpy = XOpenDisplay(NULL); + if (dpy == NULL) { + fprintf(stderr, "couldn't open display\n"); + piglit_report_result(PIGLIT_FAIL); + } + + piglit_require_glx_extension(dpy, "MESA_copy_sub_buffer"); + CopySubBuffer = (PFNGLXCOPYSUBBUFFERMESAPROC) + glXGetProcAddressARB((GLubyte *)"glXCopySubBufferMESA"); + + visinfo = piglit_get_glx_visual(dpy); + win_one = piglit_get_glx_window(dpy, visinfo); + + XMapWindow(dpy, win_one); + + piglit_glx_event_loop(dpy, draw); + + return 0; +} |