diff options
author | wm4 <wm4@nowhere> | 2017-04-06 14:50:19 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-04-06 14:50:19 +0200 |
commit | c9d3a79187a9a45ecae8e97af9b68427d1f06eac (patch) | |
tree | 97e28437706cf42e7b31c3cc8521209f8bea40ab /video/out/opengl/egl_helpers.c | |
parent | 4e6867c771a53767f9293517af8475e9d7845695 (diff) | |
download | mpv-c9d3a79187a9a45ecae8e97af9b68427d1f06eac.tar.bz2 mpv-c9d3a79187a9a45ecae8e97af9b68427d1f06eac.tar.xz |
vo_opengl: add a generic EGL function loader function
This is pretty trivial, but also quite annoying due to details like
mismatching eglGetProcAddress() function signature (most callers just
cast the function pointer), and ARM/Linux hacks. So move them all to one
place.
Diffstat (limited to 'video/out/opengl/egl_helpers.c')
-rw-r--r-- | video/out/opengl/egl_helpers.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/video/out/opengl/egl_helpers.c b/video/out/opengl/egl_helpers.c index d1ebd9aeca..ac152df06a 100644 --- a/video/out/opengl/egl_helpers.c +++ b/video/out/opengl/egl_helpers.c @@ -15,6 +15,12 @@ * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ +#include "config.h" + +#if HAVE_LIBDL +#include <dlfcn.h> +#endif + #include "common/common.h" #include "egl_helpers.h" @@ -199,3 +205,28 @@ bool mpegl_create_context_opts(EGLDisplay display, struct mp_log *log, return false; } +static void *mpegl_get_proc_address(void *ctx, const char *name) +{ + void *p = eglGetProcAddress(name); +#if defined(__GLIBC__) && HAVE_LIBDL + // Some crappy ARM/Linux things do not provide EGL 1.5, so above call does + // not necessarily return function pointers for core functions. Try to get + // them from a loaded GLES lib. As POSIX leaves RTLD_DEFAULT "reserved", + // use it only with glibc. + if (!p) + p = dlsym(RTLD_DEFAULT, name); +#endif + return p; +} + +// Load gl version and function pointers into *gl. +// Expects a current EGL context set. +void mpegl_load_functions(struct GL *gl, struct mp_log *log) +{ + const char *egl_exts = ""; + EGLDisplay display = eglGetCurrentDisplay(); + if (display != EGL_NO_DISPLAY) + egl_exts = eglQueryString(display, EGL_EXTENSIONS); + + mpgl_load_functions2(gl, mpegl_get_proc_address, NULL, egl_exts, log); +} |