From fa39dadb059bb81839b6e97e74e5b83b7c0a2a0f Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 13 May 2015 23:55:22 +0200 Subject: x11: use new OpenGL backend API --- video/out/gl_x11.c | 53 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'video/out/gl_x11.c') diff --git a/video/out/gl_x11.c b/video/out/gl_x11.c index 8310cfe7de..55099fb797 100644 --- a/video/out/gl_x11.c +++ b/video/out/gl_x11.c @@ -187,13 +187,6 @@ static bool config_window_x11(struct MPGLContext *ctx, int flags) struct vo *vo = ctx->vo; struct glx_context *glx_ctx = ctx->priv; - if (glx_ctx->context) { - // GL context and window already exist. - // Only update window geometry etc. - vo_x11_config_vo_window(vo, glx_ctx->vinfo, flags, "gl"); - return true; - } - int glx_major, glx_minor; if (!glXQueryVersion(vo->x11->display, &glx_major, &glx_minor)) { @@ -247,7 +240,7 @@ static bool config_window_x11(struct MPGLContext *ctx, int flags) glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_GREEN_SIZE, &ctx->depth_g); glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_BLUE_SIZE, &ctx->depth_b); - vo_x11_config_vo_window(vo, glx_ctx->vinfo, flags, "gl"); + vo_x11_config_vo_window(vo, glx_ctx->vinfo, flags | VOFLAG_HIDDEN, "gl"); int gl_version = ctx->requested_gl_version; bool success = false; @@ -263,7 +256,25 @@ static bool config_window_x11(struct MPGLContext *ctx, int flags) return success; } -static void releaseGlContext_x11(MPGLContext *ctx) +static int glx_init(struct MPGLContext *ctx, int vo_flags) +{ + return vo_x11_init(ctx->vo) && config_window_x11(ctx, vo_flags) ? 0 : -1; +} + +static int glx_reconfig(struct MPGLContext *ctx, int flags) +{ + struct glx_context *glx_ctx = ctx->priv; + vo_x11_config_vo_window(ctx->vo, glx_ctx->vinfo, flags, "gl"); + return 0; +} + +static int glx_control(struct MPGLContext *ctx, int *events, int request, + void *arg) +{ + return vo_x11_control(ctx->vo, events, request, arg); +} + +static void glx_uninit(MPGLContext *ctx) { struct glx_context *glx_ctx = ctx->priv; XVisualInfo **vinfo = &glx_ctx->vinfo; @@ -271,26 +282,24 @@ static void releaseGlContext_x11(MPGLContext *ctx) Display *display = ctx->vo->x11->display; if (*vinfo) XFree(*vinfo); - *vinfo = NULL; if (*context) { glXMakeCurrent(display, None, NULL); glXDestroyContext(display, *context); } - *context = 0; + vo_x11_uninit(ctx->vo); } -static void swapGlBuffers_x11(MPGLContext *ctx) +static void glx_swap_buffers(struct MPGLContext *ctx) { glXSwapBuffers(ctx->vo->x11->display, ctx->vo->x11->window); } -void mpgl_set_backend_x11(MPGLContext *ctx) -{ - ctx->priv = talloc_zero(ctx, struct glx_context); - ctx->config_window = config_window_x11; - ctx->releaseGlContext = releaseGlContext_x11; - ctx->swapGlBuffers = swapGlBuffers_x11; - ctx->vo_init = vo_x11_init; - ctx->vo_uninit = vo_x11_uninit; - ctx->vo_control = vo_x11_control; -} +const struct mpgl_driver mpgl_driver_x11 = { + .name = "x11", + .priv_size = sizeof(struct glx_context), + .init = glx_init, + .reconfig = glx_reconfig, + .swap_buffers = glx_swap_buffers, + .control = glx_control, + .uninit = glx_uninit, +}; \ No newline at end of file -- cgit v1.2.3