diff options
Diffstat (limited to 'video/out/opengl/x11egl.c')
-rw-r--r-- | video/out/opengl/x11egl.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/video/out/opengl/x11egl.c b/video/out/opengl/x11egl.c index 53cd5ae677..87e0e89fff 100644 --- a/video/out/opengl/x11egl.c +++ b/video/out/opengl/x11egl.c @@ -20,6 +20,8 @@ * version 2.1 of the License, or (at your option) any later version. */ +#include <assert.h> + #include <X11/Xlib.h> #include <EGL/egl.h> #include <EGL/eglext.h> @@ -29,11 +31,21 @@ #include "common.h" struct priv { + Display *x_display; EGLDisplay egl_display; EGLContext egl_context; EGLSurface egl_surface; }; +static _Thread_local struct priv *current_context; + +static void * GLAPIENTRY get_native_display(const char *name) +{ + if (current_context && strcmp(name, "x11") == 0) + return current_context->x_display; + return NULL; +} + static EGLConfig select_fb_config_egl(struct MPGLContext *ctx, bool es) { struct priv *p = ctx->priv; @@ -99,6 +111,8 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags) struct vo *vo = ctx->vo; bool es = flags & VOFLAG_GLES; + p->x_display = vo->x11->display; + if (!eglBindAPI(es ? EGL_OPENGL_ES_API : EGL_OPENGL_API)) { MP_FATAL(vo, "Could not bind API (%s).\n", es ? "GLES" : "GL"); return false; @@ -138,7 +152,10 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags) void *(*gpa)(const GLubyte*) = (void *(*)(const GLubyte*))eglGetProcAddress; mpgl_load_functions(ctx->gl, gpa, egl_exts, vo->log); + ctx->gl->MPGetNativeDisplay = get_native_display; + assert(!current_context); + current_context = p; return true; } @@ -171,6 +188,7 @@ static void mpegl_uninit(MPGLContext *ctx) eglDestroyContext(p->egl_display, p->egl_context); } p->egl_context = EGL_NO_CONTEXT; + current_context = NULL; vo_x11_uninit(ctx->vo); } |