diff options
author | wm4 <wm4@nowhere> | 2013-02-24 23:31:57 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-02-26 02:00:53 +0100 |
commit | c61f1ff61b8282d9938671543fa6a63d25cf5fc0 (patch) | |
tree | fbd63e42315516b1e6841db9482d3768bd86a06f /video/out/gl_common.h | |
parent | 281e10f05d02d1afe24f644a2d8b1672113630fd (diff) | |
download | mpv-c61f1ff61b8282d9938671543fa6a63d25cf5fc0.tar.bz2 mpv-c61f1ff61b8282d9938671543fa6a63d25cf5fc0.tar.xz |
gl_common: simplify window/context creation
Allow the backend code to create a GL context on best effort basis,
instead of having to implement separate functions for each variation.
This means there's only a single create_window callback now. Also,
getFunctions() doesn't have the gl3 parameter anymore, which was
confusing and hard to explain.
create_window() tries to create a GL context of any version. The field
MPGLContext.requested_gl_version is taken as a hint whether a GL3 or a
legacy context is preferred. (This should be easy on all platforms.)
The cocoa part always assumes that GL 3 is always available on
OSX 10.7.0 and higher, and miserably fails if it's not. One could try
to put more effort into probing the context, but apparently this
situation never happens, so don't bother. (And even if, mpv should be
able to fall back to vo_corevideo.)
The X11 part doesn't change much, but moving these functions around
makes the diff bigger.
Note about some corner cases:
This doesn't handle CONTEXT_FORWARD_COMPATIBLE_BIT_ARB on OpenGL 3.0
correctly. This was the one thing getFunctions() actually needed the
gl3 parameter, and we just make sure we never use forward compatible
contexts on 3.0. It should work with any version above (e.g. 3.1, 3.2
and 3.3 should be fine). This is because the GL_ARB_compatibility
extension is specified for 3.1 and up only. There doesn't seem to be
any way to detect presence of legacy GL on 3.0 with a forward
compatible context. As a counter measure, remove the FORWARD_COMPATIBLE
flags from the win32 code. Maybe this will go wrong. (Should this
happen, the flag has the be added back, and the win32 will have to
explicitly check for GL 3.0 and add "GL_ARB_compatibility" to the extra
extension string.)
Note about GLX:
Probing GL versions by trying to create a context on an existing window
was (probably) not always possible. Old code used GLX 1.2 to create
legacy contexts, and it required code different from GLX 1.3 even before
creation of the X window (the problem was selections of the X Visual).
That's why there were two functions for window creation (create_window_old
and create_window_gl3). However, the legacy context creation code was
updated to GLX 1.3 in commit b3b20cc, so having different functions for
window creation is not needed anymore.
Diffstat (limited to 'video/out/gl_common.h')
-rw-r--r-- | video/out/gl_common.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/video/out/gl_common.h b/video/out/gl_common.h index 7f516e4959..a3ab8bf287 100644 --- a/video/out/gl_common.h +++ b/video/out/gl_common.h @@ -108,7 +108,7 @@ typedef struct MPGLContext { // Bit size of each component in the created framebuffer. 0 if unknown. int depth_r, depth_g, depth_b; - // GL version requested from create_window_gl3 backend. + // GL version requested from create_window_gl3 backend (MPGL_VER mangled). // (Might be different from the actual version in gl->version.) int requested_gl_version; @@ -119,13 +119,15 @@ typedef struct MPGLContext { void (*vo_uninit)(struct vo *vo); void (*releaseGlContext)(struct MPGLContext *); - // Creates GL 1.x/2.x legacy context. - bool (*create_window_old)(struct MPGLContext *ctx, uint32_t d_width, - uint32_t d_height, uint32_t flags); - - // Creates GL 3.x core context. - bool (*create_window_gl3)(struct MPGLContext *ctx, uint32_t d_width, - uint32_t d_height, uint32_t 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.) + bool (*create_window)(struct MPGLContext *ctx, uint32_t d_width, + uint32_t d_height, uint32_t flags); // optional void (*pause)(struct vo *vo); @@ -136,9 +138,6 @@ typedef struct MPGLContext { // For free use by the backend. void *priv; - // Internal to gl_common.c. - bool (*selected_create_window)(struct MPGLContext *ctx, uint32_t d_width, - uint32_t d_height, uint32_t flags); bool vo_init_ok; } MPGLContext; |