summaryrefslogtreecommitdiffstats
path: root/video/out/gl_common.h
diff options
context:
space:
mode:
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);