[Piglit] =?y?q?=5BPATCH=203/5=5D=20Add=20gles2=20utility=20for=20OpenGL=20ES=202=2E0?=
Shuang He
shuang.he at intel.com
Fri Oct 29 00:39:58 PDT 2010
---
tests/util/CMakeLists.txt | 8 +
tests/util/piglit-egl-util.c | 447 +++++++++++++++++++++++++++++++++++
tests/util/piglit-egl-util.h | 102 ++++++++
tests/util/piglit-gles2-framework.c | 99 ++++++++
tests/util/piglit-gles2-framework.h | 31 +++
5 files changed, 687 insertions(+), 0 deletions(-)
create mode 100644 tests/util/piglit-egl-util.c
create mode 100644 tests/util/piglit-egl-util.h
create mode 100644 tests/util/piglit-gles2-framework.c
create mode 100644 tests/util/piglit-gles2-framework.h
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index faaa514..c6ee17a 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -4,6 +4,7 @@ include_directories(
${OPENGL_INCLUDE_PATH}
${GLUT_INCLUDE_DIR}
${piglit_SOURCE_DIR}/tests/util
+ ${piglit_SOURCE_DIR}/tests/util/eglut
${GLEW_INCLUDE_DIR}
)
@@ -38,4 +39,11 @@ add_library (piglitutil
IF(OPENGL_egl_LIBRARY)
add_subdirectory (eglut)
+ add_library (piglitgles2util
+ piglit-gles2-framework.c
+ piglit-egl-util.c
+ piglit-shared-util.c
+ )
+ target_link_libraries(piglitgles2util ${OPENGL_gles2_LIBRARY} pigliteglut)
+
ENDIF(OPENGL_egl_LIBRARY)
diff --git a/tests/util/piglit-egl-util.c b/tests/util/piglit-egl-util.c
new file mode 100644
index 0000000..916a9c4
--- /dev/null
+++ b/tests/util/piglit-egl-util.c
@@ -0,0 +1,447 @@
+/*
+ * Copyright (c) The Piglit project 2007
+ *
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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.
+ */
+
+#if defined(_MSC_VER)
+#include <windows.h>
+#endif
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include "piglit-egl-util.h"
+
+static GLint attr_pos = 0;
+static GLint attr_tex = 1;
+
+int
+piglit_extension_supported(const char *name)
+{
+ static const GLubyte *extensions = NULL;
+ const GLubyte *start;
+ GLubyte *where, *terminator;
+
+ /* Extension names should not have spaces. */
+ where = (GLubyte *) strchr(name, ' ');
+ if (where || *name == '\0')
+ return 0;
+
+ if (!extensions) {
+ extensions = glGetString(GL_EXTENSIONS);
+ }
+ /* It takes a bit of care to be fool-proof about parsing the
+ OpenGL extensions string. Don't be fooled by sub-strings,
+ etc. */
+ start = extensions;
+ for (;;) {
+ /* If your application crashes in the strstr routine below,
+ you are probably calling glutExtensionSupported without
+ having a current window. Calling glGetString without
+ a current OpenGL context has unpredictable results.
+ Please fix your program. */
+ where = (GLubyte *) strstr((const char *) start, name);
+ if (!where)
+ break;
+ terminator = where + strlen(name);
+ if (where == start || *(where - 1) == ' ') {
+ if (*terminator == ' ' || *terminator == '\0') {
+ return 1;
+ }
+ }
+ start = terminator;
+ }
+ return 0;
+}
+
+void piglit_require_extension(const char *name)
+{
+ if (!piglit_extension_supported(name)) {
+ printf("Test requires %s\n", name);
+ piglit_report_result(PIGLIT_SKIP);
+ exit(1);
+ }
+}
+
+void piglit_require_not_extension(const char *name)
+{
+ if (piglit_extension_supported(name)) {
+ piglit_report_result(PIGLIT_SKIP);
+ exit(1);
+ }
+}
+
+static float tolerance[4] = { 0.01, 0.01, 0.01, 0.01 };
+
+void
+piglit_set_tolerance_for_bits(int rbits, int gbits, int bbits, int abits)
+{
+ int bits[4] = {rbits, gbits, bbits, abits};
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ if (bits[i] < 2) {
+ /* Don't try to validate channels when there's only 1
+ * bit of precision (or none).
+ */
+ tolerance[i] = 1.0;
+ } else {
+ tolerance[i] = 3.0 / (1 << bits[i]);
+ }
+ }
+}
+
+/**
+ * Read a pixel from the given location and compare its RGBA value to the
+ * given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ * \return true if the color values match, false otherwise
+ */
+int piglit_probe_pixel_rgba(int x, int y, const float* expected)
+{
+ GLubyte probe[4];
+ int i;
+ GLboolean pass = GL_TRUE;
+
+ glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, probe);
+
+ for(i = 0; i < 4; ++i) {
+ if (fabs(probe[i]/255.0 - expected[i]) >= tolerance[i]) {
+ pass = GL_FALSE;
+ }
+ }
+
+ if (pass)
+ return 1;
+
+ printf("Probe at (%i,%i)\n", x, y);
+ printf(" Expected: %f %f %f %f\n", expected[0], expected[1], expected[2], expected[3]);
+ printf(" Observed: %f %f %f %f\n", probe[0]/255.0, probe[1]/255.0, probe[2]/255.0, probe[3]/255.0);
+
+ return 0;
+}
+
+int
+piglit_probe_rect_rgba(int x, int y, int w, int h, const float *expected)
+{
+ int i, j, p;
+ GLubyte *probe;
+ GLubyte *pixels = malloc(w*h*4*sizeof(GLubyte));
+
+ glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ for (j = 0; j < h; j++) {
+ for (i = 0; i < w; i++) {
+ probe = &pixels[(j*w+i)*4];
+
+ for (p = 0; p < 4; ++p) {
+ if (fabs(probe[p]/255.0 - expected[p]) >= tolerance[p]) {
+ printf("Probe at (%i,%i)\n", x+i, y+j);
+ printf(" Expected: %f %f %f %f\n",
+ expected[0], expected[1], expected[2], expected[3]);
+ printf(" Observed: %f %f %f %f\n",
+ probe[0]/255.0, probe[1]/255.0, probe[2]/255.0, probe[3]/255.0);
+
+ free(pixels);
+ return 0;
+ }
+ }
+ }
+ }
+
+ free(pixels);
+ return 1;
+}
+
+/**
+ * Read a pixel from the given location and compare its RGB value to the
+ * given expected values.
+ *
+ * Print a log message if the color value deviates from the expected value.
+ * \return true if the color values match, false otherwise
+ */
+int piglit_probe_pixel_rgb(int x, int y, const float* expected)
+{
+ GLubyte probe[3];
+ int i;
+ GLboolean pass = GL_TRUE;
+
+ glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, probe);
+
+
+ for(i = 0; i < 3; ++i) {
+ if (fabs(probe[i]/255.0 - expected[i]) >= tolerance[i]) {
+ pass = GL_FALSE;
+ }
+ }
+
+ if (pass)
+ return 1;
+
+ printf("Probe at (%i,%i)\n", x, y);
+ printf(" Expected: %f %f %f\n", expected[0], expected[1], expected[2]);
+ printf(" Observed: %f %f %f\n", probe[0]/255.0, probe[1]/255.0, probe[2]/255.0);
+
+ return 0;
+}
+
+int
+piglit_probe_rect_rgb(int x, int y, int w, int h, const float *expected)
+{
+ int i, j, p;
+ GLubyte *probe;
+ GLubyte *pixels = malloc(w*h*3*sizeof(GLubyte));
+
+ glReadPixels(x, y, w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
+
+ for (j = 0; j < h; j++) {
+ for (i = 0; i < w; i++) {
+ probe = &pixels[(j*w+i)*3];
+
+ for (p = 0; p < 3; ++p) {
+ if (fabs(probe[p]/255.0 - expected[p]) >= tolerance[p]) {
+ printf("Probe at (%i,%i)\n", x+i, y+j);
+ printf(" Expected: %f %f %f\n",
+ expected[0], expected[1], expected[2]);
+ printf(" Observed: %f %f %f\n",
+ probe[0]/255.0, probe[1]/255.0, probe[2]/255.0);
+
+ free(pixels);
+ return 0;
+ }
+ }
+ }
+ }
+
+ free(pixels);
+ return 1;
+}
+
+void
+piglit_escape_exit_key(unsigned char key, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+}
+
+/**
+ * Convenience function to draw an axis-aligned rectangle.
+ */
+GLvoid
+piglit_draw_rect(float x, float y, float w, float h)
+{
+ float verts[4][4];
+
+ verts[0][0] = x;
+ verts[0][1] = y;
+ verts[0][2] = 0.0;
+ verts[0][3] = 1.0;
+ verts[1][0] = x + w;
+ verts[1][1] = y;
+ verts[1][2] = 0.0;
+ verts[1][3] = 1.0;
+ verts[2][0] = x;
+ verts[2][1] = y + h;
+ verts[2][2] = 0.0;
+ verts[2][3] = 1.0;
+ verts[3][0] = x + w;
+ verts[3][1] = y + h;
+ verts[3][2] = 0.0;
+ verts[3][3] = 1.0;
+
+ glVertexAttribPointer(attr_pos, 4, GL_FLOAT, GL_FALSE, 0, verts);
+ glEnableVertexAttribArray(attr_pos);
+
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ glDisableVertexAttribArray(attr_pos);
+}
+
+/**
+ * Convenience function to draw an axis-aligned rectangle.
+ */
+GLvoid
+piglit_draw_rect_z(float z, float x, float y, float w, float h)
+{
+ float verts[4][4];
+
+ verts[0][0] = x;
+ verts[0][1] = y;
+ verts[0][2] = z;
+ verts[0][3] = 1.0;
+ verts[1][0] = x + w;
+ verts[1][1] = y;
+ verts[1][2] = z;
+ verts[1][3] = 1.0;
+ verts[2][0] = x;
+ verts[2][1] = y + h;
+ verts[2][2] = z;
+ verts[2][3] = 1.0;
+ verts[3][0] = x + w;
+ verts[3][1] = y + h;
+ verts[3][2] = z;
+ verts[3][3] = 1.0;
+
+ glVertexAttribPointer(attr_pos, 4, GL_FLOAT, GL_FALSE, 0, verts);
+ glEnableVertexAttribArray(attr_pos);
+
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ glDisableVertexAttribArray(attr_pos);
+}
+
+/**
+ * Convenience function to draw an axis-aligned rectangle
+ * with texture coordinates.
+ */
+GLvoid
+piglit_draw_rect_tex(float x, float y, float w, float h,
+ float tx, float ty, float tw, float th)
+{
+ float verts[4][4];
+ float tex[4][2];
+
+ verts[0][0] = x;
+ verts[0][1] = y;
+ verts[0][2] = 0.0;
+ verts[0][3] = 1.0;
+ tex[0][0] = tx;
+ tex[0][1] = ty;
+ verts[1][0] = x + w;
+ verts[1][1] = y;
+ verts[1][2] = 0.0;
+ verts[1][3] = 1.0;
+ tex[1][0] = tx + tw;
+ tex[1][1] = ty;
+ verts[2][0] = x + w;
+ verts[2][1] = y + h;
+ verts[2][2] = 0.0;
+ verts[2][3] = 1.0;
+ tex[2][0] = tx + tw;
+ tex[2][1] = ty + th;
+ verts[3][0] = x;
+ verts[3][1] = y + h;
+ verts[3][2] = 0.0;
+ verts[3][3] = 1.0;
+ tex[3][0] = tx;
+ tex[3][1] = ty + th;
+
+ glVertexAttribPointer(attr_pos, 4, GL_FLOAT, GL_FALSE, 0, verts);
+ glVertexAttribPointer(attr_tex, 2, GL_FLOAT, GL_FALSE, 0, tex);
+ glEnableVertexAttribArray(attr_pos);
+ glEnableVertexAttribArray(attr_tex);
+
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ glDisableVertexAttribArray(attr_pos);
+ glDisableVertexAttribArray(attr_tex);
+}
+
+/**
+ * Generate a checkerboard texture
+ *
+ * \param tex Name of the texture to be used. If \c tex is
+ * zero, a new texture name will be generated.
+ * \param level Mipmap level the checkerboard should be written to
+ * \param width Width of the texture image
+ * \param height Height of the texture image
+ * \param horiz_square_size Size of each checkerboard tile along the X axis
+ * \param vert_square_size Size of each checkerboard tile along the Y axis
+ * \param black RGBA color to be used for "black" tiles
+ * \param white RGBA color to be used for "white" tiles
+ *
+ * A texture with alternating black and white squares in a checkerboard
+ * pattern is generated. The texture data is written to LOD \c level of
+ * the texture \c tex.
+ *
+ * If \c tex is zero, a new texture created. This texture will have several
+ * texture parameters set to non-default values:
+ *
+ * - S and T wrap modes will be set to \c GL_CLAMP_TO_BORDER.
+ * - Border color will be set to { 1.0, 0.0, 0.0, 1.0 }.
+ * - Min and mag filter will be set to \c GL_NEAREST.
+ *
+ * \return
+ * Name of the texture. In addition, this texture will be bound to the
+ * \c GL_TEXTURE_2D target of the currently active texture unit.
+ */
+GLuint
+piglit_checkerboard_texture(GLuint tex, unsigned level,
+ unsigned width, unsigned height,
+ unsigned horiz_square_size,
+ unsigned vert_square_size,
+ const float *black, const float *white)
+{
+ unsigned i;
+ unsigned j;
+
+ float *const tex_data = malloc(width * height * (4 * sizeof(float)));
+ float *texel = tex_data;
+
+ for (i = 0; i < height; i++) {
+ const unsigned row = i / vert_square_size;
+
+ for (j = 0; j < width; j++) {
+ const unsigned col = j / horiz_square_size;
+
+ if ((row ^ col) & 1) {
+ memcpy(texel, white, 4 * sizeof(float));
+ } else {
+ memcpy(texel, black, 4 * sizeof(float));
+ }
+
+ texel += 4;
+ }
+ }
+
+
+ if (tex == 0) {
+ glGenTextures(1, &tex);
+
+ glBindTexture(GL_TEXTURE_2D, tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+ GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+ GL_CLAMP_TO_EDGE);
+ } else {
+ glBindTexture(GL_TEXTURE_2D, tex);
+ }
+
+ glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, width, height, 0, GL_RGBA,
+ GL_FLOAT, tex_data);
+
+ return tex;
+}
diff --git a/tests/util/piglit-egl-util.h b/tests/util/piglit-egl-util.h
new file mode 100644
index 0000000..8951c9b
--- /dev/null
+++ b/tests/util/piglit-egl-util.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) The Piglit project 2007
+ *
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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.
+ */
+
+#if defined(_MSC_VER)
+#include <windows.h>
+
+typedef __int32 int32_t;
+typedef __int64 int64_t;
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int64 uint64_t;
+#else
+#include <stdint.h>
+#endif
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GLES2/gl2.h>
+
+#if defined(_MSC_VER)
+
+#define snprintf sprintf_s
+
+#define piglit_get_proc_address(x) wglGetProcAddress(x)
+#else
+#define piglit_get_proc_address(x) glutGetProcAddress(x)
+#endif
+
+enum piglit_result {
+ PIGLIT_SUCCESS,
+ PIGLIT_FAILURE,
+ PIGLIT_SKIP,
+ PIGLIT_WARN
+};
+
+#include "piglit-gles2-framework.h"
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+
+extern const uint8_t fdo_bitmap[];
+extern const unsigned int fdo_bitmap_width;
+extern const unsigned int fdo_bitmap_height;
+
+int FindLine(const char *program, int position);
+void piglit_report_result(enum piglit_result result);
+void piglit_require_extension(const char *name);
+void piglit_require_not_extension(const char *name);
+int piglit_probe_pixel_rgb(int x, int y, const float* expected);
+int piglit_probe_pixel_rgba(int x, int y, const float* expected);
+int piglit_probe_rect_rgb(int x, int y, int w, int h, const float* expected);
+int piglit_probe_rect_rgba(int x, int y, int w, int h, const float* expected);
+
+GLuint piglit_compile_shader(GLenum target, char *filename);
+GLuint piglit_compile_shader_text(GLenum target, const char *text);
+GLboolean piglit_link_check_status(GLint prog);
+GLint piglit_link_simple_program(GLint vs, GLint fs);
+GLvoid piglit_draw_rect(float x, float y, float w, float h);
+GLvoid piglit_draw_rect_z(float z, float x, float y, float w, float h);
+GLvoid piglit_draw_rect_tex(float x, float y, float w, float h,
+ float tx, float ty, float tw, float th);
+void piglit_escape_exit_key(unsigned char key, int x, int y);
+
+char *piglit_load_text_file(const char *file_name, unsigned *size);
+
+GLuint piglit_checkerboard_texture(GLuint tex, unsigned level,
+ unsigned width, unsigned height,
+ unsigned horiz_square_size, unsigned vert_square_size,
+ const float *black, const float *white);
+GLuint piglit_rgbw_texture(GLenum format, int w, int h, GLboolean mip,
+ GLboolean alpha);
+void piglit_set_tolerance_for_bits(int rbits, int gbits, int bbits, int abits);
+
+extern GLfloat cube_face_texcoords[6][4][3];
+extern const char *cube_face_names[6];
+extern const GLenum cube_face_targets[6];
+
+#ifndef HAVE_STRCHRNUL
+char *strchrnul(const char *s, int c);
+#endif
diff --git a/tests/util/piglit-gles2-framework.c b/tests/util/piglit-gles2-framework.c
new file mode 100644
index 0000000..8fe9cbd
--- /dev/null
+++ b/tests/util/piglit-gles2-framework.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright © 2010 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.
+ */
+
+/**
+ * Simple test case framework.
+ *
+ * \author Shuang He <shuang.he at intel.com>
+ */
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "piglit-egl-util.h"
+#include "piglit-gles2-framework.h"
+#include "eglut.h"
+
+int piglit_automatic = 0;
+static int piglit_window;
+static enum piglit_result result;
+
+static void
+display(void)
+{
+ result = piglit_egl_display();
+
+ if (piglit_automatic) {
+ eglutDestroyWindow(piglit_window);
+ piglit_report_result(result);
+ }
+}
+
+static void
+reshape(int w, int h)
+{
+ piglit_width = w;
+ piglit_height = h;
+
+ glViewport(0, 0, w, h);
+}
+
+int main(int argc, char *argv[])
+{
+ int j;
+
+ eglutInit(argc, argv);
+
+ /* Find/remove "-auto" from the argument vector.
+ */
+ for (j = 1; j < argc; j++) {
+ if (!strcmp(argv[j], "-auto")) {
+ int i;
+
+ piglit_automatic = 1;
+
+ for (i = j + 1; i < argc; i++) {
+ argv[i - 1] = argv[i];
+ }
+ argc--;
+ j--;
+ }
+ }
+ eglutInitWindowSize(piglit_width, piglit_height);
+ eglutInitAPIMask(EGLUT_OPENGL_ES2_BIT);
+ eglutCreateWindow(argv[0]);
+
+ eglutDisplayFunc(display);
+ eglutReshapeFunc(reshape);
+ eglutKeyboardFunc((EGLUTkeyboardCB)piglit_escape_exit_key);
+
+ piglit_egl_init(argc, argv);
+
+ eglutMainLoop();
+
+ piglit_report_result(result);
+ /* UNREACHED */
+ return 0;
+}
diff --git a/tests/util/piglit-gles2-framework.h b/tests/util/piglit-gles2-framework.h
new file mode 100644
index 0000000..6eac52e
--- /dev/null
+++ b/tests/util/piglit-gles2-framework.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2009 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.
+ */
+
+extern int piglit_automatic;
+
+extern int piglit_window_mode;
+extern int piglit_width;
+extern int piglit_height;
+
+extern enum piglit_result piglit_egl_display(void);
+extern void piglit_egl_init(int argc, char **argv);
--
1.7.2.3
More information about the Piglit
mailing list