From 540952010bc2707bedfbbfe89c77d1a1640e76ae Mon Sep 17 00:00:00 2001 From: Yaron Cohen-Tal Date: Sun, 19 Jul 2015 20:55:36 +0300 Subject: [PATCH] Fix tests to work with some OpenGL ES / EGL implementations. --- README.md | 3 ++- test/egl_and_glx_different_pointers.c | 10 ++++---- test/egl_common.c | 10 ++++---- test/egl_common.h | 2 +- test/egl_gl.c | 8 +++--- test/egl_has_extension_nocontext.c | 2 +- test/egl_without_glx.c | 36 +++++---------------------- 7 files changed, 24 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 7530a9d..910a6f9 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Building (Unix) ./autogen.sh make + make check [optional] sudo make install Dependencies for debian: @@ -51,7 +52,7 @@ Building (MSVC 2013) 1) Check src\Makefile.vc to ensure that PYTHONDIR is pointing to your Python installation, either a 32-bit or a 64-bit (x64) installation of Python will do. 2) Open an MSVC Command prompt and run "nmake Makefile.vc CFG=release" or "nmake Makefile.vc CFG=debug" in src\ for a release or debug build. 3) Optionally, add src\ into your PATH and run the previous step in test\. Run the tests by running the built .exe's. -4) Assuming you want to install in %INSTALL_DIR%, copy gl.h, gl_generated.h, wgl.h, wgl_generated.h, egl.h and egl_generated.h from include\epoxy\ to %INSTALL_DIR%\include\epoxy\, copy src\epoxy.lib to %INSTALL_DIR%\lib\ and copy epoxy-vs12.dll and epoxy-vs12.pdb (if you've built a debug build) from src\ to %INSTALL_DIR%\bin\. Create directories as needed. +4) Assuming you want to install in %INSTALL_DIR%, copy common.h, gl.h, gl_generated.h, wgl.h, wgl_generated.h, egl.h and egl_generated.h from include\epoxy\ to %INSTALL_DIR%\include\epoxy\, copy src\epoxy.lib to %INSTALL_DIR%\lib\ and copy epoxy-vs12.dll and epoxy-vs12.pdb (if you've built a debug build) from src\ to %INSTALL_DIR%\bin\. Create directories as needed. 5) To clean the project, repeat steps 2 and 3, adding " clean" to the commands. Switching your code to using epoxy diff --git a/test/egl_and_glx_different_pointers.c b/test/egl_and_glx_different_pointers.c index 2a2ff3c..9d95f3a 100644 --- a/test/egl_and_glx_different_pointers.c +++ b/test/egl_and_glx_different_pointers.c @@ -136,7 +136,7 @@ init_glx(Display **out_dpy, GLXContext *out_ctx, Drawable *out_draw) #ifdef USE_EGL static bool -make_egl_current_and_test(EGLDisplay *dpy, EGLContext ctx) +make_egl_current_and_test(EGLDisplay dpy, EGLContext ctx) { const char *string; GLuint shader; @@ -171,15 +171,15 @@ make_egl_current_and_test(EGLDisplay *dpy, EGLContext ctx) } static void -init_egl(EGLDisplay **out_dpy, EGLContext *out_ctx) +init_egl(EGLDisplay *out_dpy, EGLContext *out_ctx) { - EGLDisplay *dpy = get_egl_display_or_skip(); + EGLDisplay dpy = get_egl_display_or_skip(); static const EGLint config_attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 1, EGL_GREEN_SIZE, 1, EGL_BLUE_SIZE, 1, - EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE }; static const EGLint context_attribs[] = { @@ -212,7 +212,7 @@ main(int argc, char **argv) { bool pass = true; #ifdef USE_EGL - EGLDisplay *egl_dpy; + EGLDisplay egl_dpy; EGLContext egl_ctx; #endif #ifdef USE_GLX diff --git a/test/egl_common.c b/test/egl_common.c index d2f11a3..b1ca06f 100644 --- a/test/egl_common.c +++ b/test/egl_common.c @@ -24,25 +24,25 @@ #include #include #include "egl_common.h" +#include /** * Do whatever it takes to get us an EGL display for the system. * * This needs to be ported to other window systems. */ -EGLDisplay * +EGLDisplay get_egl_display_or_skip(void) { Display *dpy = XOpenDisplay(NULL); EGLint major, minor; - EGLDisplay *edpy; + EGLDisplay edpy; bool ok; if (!dpy) errx(77, "couldn't open display\n"); - - edpy = eglGetDisplay(dpy); - if (!edpy) + edpy = eglGetDisplay((EGLNativeDisplayType)dpy); + if (edpy == EGL_NO_DISPLAY) errx(1, "Couldn't get EGL display for X11 Display.\n"); ok = eglInitialize(edpy, &major, &minor); diff --git a/test/egl_common.h b/test/egl_common.h index 1c5963b..93571dc 100644 --- a/test/egl_common.h +++ b/test/egl_common.h @@ -21,5 +21,5 @@ * IN THE SOFTWARE. */ -EGLDisplay * +EGLDisplay get_egl_display_or_skip(void); diff --git a/test/egl_gl.c b/test/egl_gl.c index c3fb3c2..99576d3 100644 --- a/test/egl_gl.c +++ b/test/egl_gl.c @@ -44,7 +44,7 @@ #include "dlwrap.h" static bool -make_egl_current_and_test(EGLDisplay *dpy, EGLContext ctx) +make_egl_current_and_test(EGLDisplay dpy, EGLContext ctx) { const char *string; GLuint shader; @@ -73,9 +73,9 @@ make_egl_current_and_test(EGLDisplay *dpy, EGLContext ctx) } static void -init_egl(EGLDisplay **out_dpy, EGLContext *out_ctx) +init_egl(EGLDisplay *out_dpy, EGLContext *out_ctx) { - EGLDisplay *dpy = get_egl_display_or_skip(); + EGLDisplay dpy = get_egl_display_or_skip(); static const EGLint config_attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 1, @@ -113,7 +113,7 @@ int main(int argc, char **argv) { bool pass = true; - EGLDisplay *egl_dpy; + EGLDisplay egl_dpy; EGLContext egl_ctx; /* Force epoxy to have loaded both EGL and GLX libs already -- we diff --git a/test/egl_has_extension_nocontext.c b/test/egl_has_extension_nocontext.c index 94a7faa..e8c76a8 100644 --- a/test/egl_has_extension_nocontext.c +++ b/test/egl_has_extension_nocontext.c @@ -43,7 +43,7 @@ main(int argc, char **argv) { bool pass = true; - EGLDisplay *dpy = get_egl_display_or_skip(); + EGLDisplay dpy = get_egl_display_or_skip(); const char *extensions = eglQueryString(dpy, EGL_EXTENSIONS); char *first_space; char *an_extension; diff --git a/test/egl_without_glx.c b/test/egl_without_glx.c index 9326b5a..c3dcc22 100644 --- a/test/egl_without_glx.c +++ b/test/egl_without_glx.c @@ -43,34 +43,6 @@ #include "egl_common.h" -/** - * Wraps the system dlopen(), which libepoxy will end up calling when - * it tries to dlopen() the API libraries, and errors out the - * libraries we're trying to simulate not being installed on the - * system. - */ -void * -dlopen(const char *filename, int flag) -{ - void * (*dlopen_unwrapped)(const char *filename, int flag); - - if (!strcmp(filename, "libGL.so.1")) - return NULL; -#if GLES_VERSION == 2 - if (!strcmp(filename, "libGLESv1_CM.so.1")) - return NULL; -#else - if (!strcmp(filename, "libGLESv2.so.2")) - return NULL; -#endif - - dlopen_unwrapped = dlsym(RTLD_NEXT, "dlopen"); - assert(dlopen_unwrapped); - - return dlopen_unwrapped(filename, flag); -} - - static EGLenum last_api; static EGLenum extra_error = EGL_SUCCESS; @@ -119,7 +91,7 @@ int main(int argc, char **argv) { bool pass = true; - EGLDisplay *dpy = get_egl_display_or_skip(); + EGLDisplay dpy = get_egl_display_or_skip(); EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, GLES_VERSION, EGL_NONE @@ -130,7 +102,11 @@ main(int argc, char **argv) EGL_RED_SIZE, 1, EGL_GREEN_SIZE, 1, EGL_BLUE_SIZE, 1, - EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, +#if GLES_VERSION == 2 + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, +#else + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT, +#endif EGL_NONE }; EGLint count;