Commit e1cdb462 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

EGL: support non-default X11 display

parent 8bd96cd9
...@@ -68,6 +68,9 @@ typedef struct vlc_gl_sys_t ...@@ -68,6 +68,9 @@ typedef struct vlc_gl_sys_t
EGLDisplay display; EGLDisplay display;
EGLSurface surface; EGLSurface surface;
EGLContext context; EGLContext context;
#if defined (USE_PLATFORM_X11)
Display *x11;
#endif
} vlc_gl_sys_t; } vlc_gl_sys_t;
/* OpenGL callbacks */ /* OpenGL callbacks */
...@@ -138,12 +141,28 @@ static int Open (vlc_object_t *obj, const struct gl_api *api) ...@@ -138,12 +141,28 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
sys->display = EGL_NO_DISPLAY; sys->display = EGL_NO_DISPLAY;
#ifdef USE_PLATFORM_X11 #ifdef USE_PLATFORM_X11
if (wnd->type != VOUT_WINDOW_TYPE_XID || wnd->display.x11 != NULL sys->x11 = NULL;
|| !vlc_xlib_init(obj))
if (wnd->type != VOUT_WINDOW_TYPE_XID || !vlc_xlib_init(obj))
goto error; goto error;
sys->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); sys->x11 = XOpenDisplay(wnd->display.x11);
window = wnd->handle.xid; if (sys->x11 == NULL)
goto error;
int snum;
{
XWindowAttributes wa;
if (!XGetWindowAttributes(sys->x11, wnd->handle.xid, &wa))
goto error;
snum = XScreenNumberOfScreen(wa.screen);
}
if (snum == XDefaultScreen(sys->x11))
{
sys->display = eglGetDisplay(sys->x11);
window = wnd->handle.xid;
}
#elif defined (USE_PLATFORM_WIN32) #elif defined (USE_PLATFORM_WIN32)
if (wnd->type != VOUT_WINDOW_TYPE_HWND) if (wnd->type != VOUT_WINDOW_TYPE_HWND)
...@@ -264,6 +283,10 @@ static void Close (vlc_object_t *obj) ...@@ -264,6 +283,10 @@ static void Close (vlc_object_t *obj)
if (sys->display != EGL_NO_DISPLAY) if (sys->display != EGL_NO_DISPLAY)
eglTerminate(sys->display); eglTerminate(sys->display);
#ifdef USE_PLATFORM_X11
if (sys->x11 != NULL)
XCloseDisplay(sys->x11);
#endif
free (sys); free (sys);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment