summaryrefslogtreecommitdiffstats
path: root/video/out/gl_common.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-26 20:48:11 +0100
committerwm4 <wm4@nowhere>2014-11-26 20:48:18 +0100
commit3fe57e3cb691d75dc8813c29cada5e3ddfd2a295 (patch)
tree93962472662b8d3c402d97cd3f78b91f2d0f4c89 /video/out/gl_common.c
parent7e62f2b0527e2a4d96418b9d8009dd840a45df0c (diff)
downloadmpv-3fe57e3cb691d75dc8813c29cada5e3ddfd2a295.tar.bz2
mpv-3fe57e3cb691d75dc8813c29cada5e3ddfd2a295.tar.xz
gl_common: factor context creation
Always create the context in mpgl_init(), instead of doing it when mpgl_config_window() is called the first time. This is a small step towards cleaning up the GL backend interface, and adding other things like perhaps GLES support, or a callback-driven backend for libmpv.
Diffstat (limited to 'video/out/gl_common.c')
-rw-r--r--video/out/gl_common.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/video/out/gl_common.c b/video/out/gl_common.c
index 195ad72539..4d0a3c8dd4 100644
--- a/video/out/gl_common.c
+++ b/video/out/gl_common.c
@@ -930,7 +930,7 @@ static MPGLContext *init_backend(struct vo *vo, MPGLSetBackendFn set_backend,
return ctx;
}
-MPGLContext *mpgl_init(struct vo *vo, const char *backend_name)
+static MPGLContext *mpgl_create(struct vo *vo, const char *backend_name)
{
MPGLContext *ctx = NULL;
int index = mpgl_find_backend(backend_name);
@@ -946,17 +946,22 @@ MPGLContext *mpgl_init(struct vo *vo, const char *backend_name)
return ctx;
}
-bool mpgl_config_window(struct MPGLContext *ctx, int gl_caps, int flags)
+MPGLContext *mpgl_init(struct vo *vo, const char *backend_name,
+ int gl_caps, int vo_flags)
{
+ MPGLContext *ctx = mpgl_create(vo, backend_name);
+ if (!ctx)
+ return NULL;
+
gl_caps |= MPGL_CAP_GL;
ctx->requested_gl_version = (gl_caps & MPGL_CAP_GL_LEGACY)
? MPGL_VER(2, 1) : MPGL_VER(3, 0);
- if (ctx->config_window(ctx, flags)) {
+ if (ctx->config_window(ctx, vo_flags | VOFLAG_HIDDEN)) {
int missing = (ctx->gl->mpgl_caps & gl_caps) ^ gl_caps;
if (!missing)
- return true;
+ return ctx;
MP_WARN(ctx->vo, "Missing OpenGL features:");
list_features(missing, ctx->vo->log, MSGL_WARN, false);
@@ -970,7 +975,13 @@ bool mpgl_config_window(struct MPGLContext *ctx, int gl_caps, int flags)
}
MP_ERR(ctx->vo, "OpenGL context creation failed!\n");
- return false;
+ mpgl_uninit(ctx);
+ return NULL;
+}
+
+bool mpgl_reconfig_window(struct MPGLContext *ctx, int flags)
+{
+ return ctx->config_window(ctx, flags);
}
void mpgl_uninit(MPGLContext *ctx)