summaryrefslogtreecommitdiffstats
path: root/video/out/gl_common.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-13 23:55:07 +0200
committerwm4 <wm4@nowhere>2015-05-14 00:05:43 +0200
commitdf97c30e0e324a7a51c3cb4a24eb27fcf30462b2 (patch)
tree4ac7c8ebec7cc932ef96c80f128c79a7ce8c3383 /video/out/gl_common.h
parent10de9b091a59e4831bb3fbfc46eb1d3c7558c9d8 (diff)
downloadmpv-df97c30e0e324a7a51c3cb4a24eb27fcf30462b2.tar.bz2
mpv-df97c30e0e324a7a51c3cb4a24eb27fcf30462b2.tar.xz
vo_opengl: create new API for OpenGL VO backends
An attempt to get rid of the weird mix of callbacks that take either struct vo or MPGLCopntext as parameter. This is not perfect, and the API will probably change a bit until all other code is ported to it. the main question is how to separate struct vo completely from the windowing code, which actually needs vo for very little. In the end, the legacy callbacks will be dropped.
Diffstat (limited to 'video/out/gl_common.h')
-rw-r--r--video/out/gl_common.h49
1 files changed, 46 insertions, 3 deletions
diff --git a/video/out/gl_common.h b/video/out/gl_common.h
index 7d037cd518..711db271bd 100644
--- a/video/out/gl_common.h
+++ b/video/out/gl_common.h
@@ -74,9 +74,47 @@ enum {
#define MPGL_VER_P(ver) MPGL_VER_GET_MAJOR(ver), MPGL_VER_GET_MINOR(ver)
+struct MPGLContext;
+
+// A backend (like X11, win32, ...), which provides OpenGL rendering.
+// This should be preferred for new code, instead of setting the callbacks
+// in MPGLContext directly.
+struct mpgl_driver {
+ const char *name;
+
+ // Size of the struct allocated for MPGLContext.priv
+ int priv_size;
+
+ // Init the GL context and possibly the underlying VO backend.
+ // Return 0 on success, negative value (-1) on error.
+ int (*init)(struct MPGLContext *ctx, int vo_flags);
+
+ // Resize the window, or create a new window if there isn't one yet.
+ // On the first call, it creates a GL context according to what's specified
+ // in MPGLContext.requested_gl_version. This is just a hint, and if the
+ // requested version is not available, it may return a completely different
+ // GL context. (The caller must check if the created GL version is ok. The
+ // callee must try to fall back to an older version if the requested
+ // version is not available, and newer versions are incompatible.)
+ // Currently, there is an unfortunate interaction with ctx->vo, and
+ // display size etc. are determined by it.
+ // Return 0 on success, negative value (-1) on error.
+ int (*reconfig)(struct MPGLContext *ctx, int flags);
+
+ // Present the frame.
+ void (*swap_buffers)(struct MPGLContext *ctx);
+
+ // This behaves exactly like vo_driver.control().
+ int (*control)(struct MPGLContext *ctx, int *events, int request, void *arg);
+
+ // Destroy the GL context and possibly the underlying VO backend.
+ void (*uninit)(struct MPGLContext *ctx);
+};
+
typedef struct MPGLContext {
GL *gl;
struct vo *vo;
+ const struct mpgl_driver *driver;
// Bit size of each component in the created framebuffer. 0 if unknown.
int depth_r, depth_g, depth_b;
@@ -85,6 +123,12 @@ typedef struct MPGLContext {
// (Might be different from the actual version in gl->version.)
int requested_gl_version;
+ // For free use by the mpgl_driver.
+ void *priv;
+
+ // Warning: all callbacks below are legacy. Newer code should use
+ // a mpgl_driver struct, which replaces these callbacks.
+
void (*swapGlBuffers)(struct MPGLContext *);
int (*vo_init)(struct vo *vo);
void (*vo_uninit)(struct vo *vo);
@@ -110,14 +154,13 @@ typedef struct MPGLContext {
// with swapGlBuffers(). This returns false if use of the OpenGL context
// should be avoided.
bool (*start_frame)(struct MPGLContext *);
-
- // For free use by the backend.
- void *priv;
} MPGLContext;
MPGLContext *mpgl_init(struct vo *vo, const char *backend_name, int vo_flags);
void mpgl_uninit(MPGLContext *ctx);
bool mpgl_reconfig_window(struct MPGLContext *ctx, int vo_flags);
+int mpgl_control(struct MPGLContext *ctx, int *events, int request, void *arg);
+void mpgl_swap_buffers(struct MPGLContext *ctx);
int mpgl_find_backend(const char *name);