The fbo code has already been moved into piglit-framework-fbo.*. For symmetry and clarity, the glut code should exist in its own module too.
As a bonus, this refactor gives piglit-framework.c a well-defined purpose: to parse argv and then dispatch the testrun to either piglit-framework-fbo or piglit-framework-glut. Signed-off-by: Chad Versace <chad.vers...@linux.intel.com> --- tests/util/CMakeLists.txt | 1 + tests/util/piglit-framework-glut.c | 108 ++++++++++++++++++++++++++++++++++++ tests/util/piglit-framework-glut.h | 28 ++++++++++ tests/util/piglit-framework.c | 74 +----------------------- 4 files changed, 138 insertions(+), 73 deletions(-) create mode 100644 tests/util/piglit-framework-glut.c create mode 100644 tests/util/piglit-framework-glut.h diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt index 5ebbb81..721e35f 100644 --- a/tests/util/CMakeLists.txt +++ b/tests/util/CMakeLists.txt @@ -18,6 +18,7 @@ set(UTIL_SOURCES shader-load.c piglit-framework.c piglit-framework-fbo.c + piglit-framework-glut.c rgb9e5.c ) diff --git a/tests/util/piglit-framework-glut.c b/tests/util/piglit-framework-glut.c new file mode 100644 index 0000000..fdb76fb --- /dev/null +++ b/tests/util/piglit-framework-glut.c @@ -0,0 +1,108 @@ +/* + * Copyright 2009-2012 Intel Corporation + * + * 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. + */ + +#include <assert.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> + +#include "piglit-util.h" +#include "piglit-framework.h" +#include "piglit-framework-glut.h" + +#ifdef USE_GLX +#include "piglit-glx-util.h" +#endif + +static int piglit_window; +static enum piglit_result result; + + +static void +display(void) +{ + result = piglit_display(); + + if (piglit_automatic) { + glutDestroyWindow(piglit_window); +#ifdef FREEGLUT + /* Tell GLUT to clean up and exit, so that we can + * reasonably valgrind our testcases for memory + * leaks by the GL. + */ + glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, + GLUT_ACTION_GLUTMAINLOOP_RETURNS); + glutLeaveMainLoop(); +#else + piglit_report_result(result); +#endif + } +} + +static void +reshape(int w, int h) +{ + piglit_width = w; + piglit_height = h; + + glViewport(0, 0, w, h); +} + +/* Swapbuffers the results to the window in non-auto mode. */ +void +piglit_present_results() +{ + if (!piglit_automatic && !piglit_use_fbo) + glutSwapBuffers(); +} + +void +piglit_framework_glut_init(int argc, char *argv[]) +{ + piglit_glutInit(argc, argv); + + glutInitWindowPosition(0, 0); + glutInitWindowSize(piglit_width, piglit_height); + glutInitDisplayMode(piglit_window_mode); + piglit_window = glutCreateWindow(argv[0]); + +#if defined(USE_GLX) && !defined(USE_WAFFLE) + /* If using waffle, then the current platform might not be GLX. + * So we can't call any GLX functions. + * + * FIXME: Detect the waffle platform and handle piglit_automatic + * FIXME: appropriately. + */ + if (piglit_automatic) + piglit_glx_set_no_input(); +#endif + + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(piglit_escape_exit_key); + +#ifdef USE_OPENGL + glewInit(); +#endif +} diff --git a/tests/util/piglit-framework-glut.h b/tests/util/piglit-framework-glut.h new file mode 100644 index 0000000..60bcc00 --- /dev/null +++ b/tests/util/piglit-framework-glut.h @@ -0,0 +1,28 @@ +/* + * Copyright 2012 Intel Corporation + * + * 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. + */ + +#pragma once + +#include "piglit-util.h" + +void piglit_framework_glut_init(int argc, char *argv[]); diff --git a/tests/util/piglit-framework.c b/tests/util/piglit-framework.c index 1a0a0a8..6e5ae34 100644 --- a/tests/util/piglit-framework.c +++ b/tests/util/piglit-framework.c @@ -35,16 +35,12 @@ #include "piglit-util.h" #include "piglit-framework.h" #include "piglit-framework-fbo.h" - -#ifdef USE_GLX -#include "piglit-glx-util.h" -#endif +#include "piglit-framework-glut.h" bool piglit_use_fbo = false; int piglit_automatic = 0; unsigned piglit_winsys_fbo = 0; -static int piglit_window; static enum piglit_result result; #ifndef _WIN32 @@ -62,74 +58,6 @@ __attribute__((weak)) void piglit_init(int argc, char **argv) #endif static void -display(void) -{ - result = piglit_display(); - - if (piglit_automatic) { - glutDestroyWindow(piglit_window); -#ifdef FREEGLUT - /* Tell GLUT to clean up and exit, so that we can - * reasonably valgrind our testcases for memory - * leaks by the GL. - */ - glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, - GLUT_ACTION_GLUTMAINLOOP_RETURNS); - glutLeaveMainLoop(); -#else - piglit_report_result(result); -#endif - } -} - -static void -reshape(int w, int h) -{ - piglit_width = w; - piglit_height = h; - - glViewport(0, 0, w, h); -} - -/* Swapbuffers the results to the window in non-auto mode. */ -void -piglit_present_results() -{ - if (!piglit_automatic && !piglit_use_fbo) - glutSwapBuffers(); -} - -static void -piglit_framework_glut_init(int argc, char *argv[]) -{ - piglit_glutInit(argc, argv); - - glutInitWindowPosition(0, 0); - glutInitWindowSize(piglit_width, piglit_height); - glutInitDisplayMode(piglit_window_mode); - piglit_window = glutCreateWindow(argv[0]); - -#if defined(USE_GLX) && !defined(USE_WAFFLE) - /* If using waffle, then the current platform might not be GLX. - * So we can't call any GLX functions. - * - * FIXME: Detect the waffle platform and handle piglit_automatic - * FIXME: appropriately. - */ - if (piglit_automatic) - piglit_glx_set_no_input(); -#endif - - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(piglit_escape_exit_key); - -#ifdef USE_OPENGL - glewInit(); -#endif -} - -static void delete_arg(char *argv[], int argc, int arg) { int i; -- 1.7.10.4 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit