summaryrefslogtreecommitdiffstats
path: root/libvo/vo_gl.c
diff options
context:
space:
mode:
authorwm4 <wm4@mplayer2.org>2011-09-29 22:20:46 +0200
committerUoti Urpala <uau@mplayer2.org>2011-10-24 06:14:19 +0300
commitbb8781a00a590412926f240fd0731a25127eb046 (patch)
tree03d4c7aef466dffdfa6db6426e98820b00dd35c8 /libvo/vo_gl.c
parent98b89d4aa78dc62317300ac59e8bd4b1d5d80977 (diff)
downloadmpv-bb8781a00a590412926f240fd0731a25127eb046.tar.bz2
mpv-bb8781a00a590412926f240fd0731a25127eb046.tar.xz
vo_gl: add new vo name "gl_sdl" to make SDL+GL mode available
The actual work is done by the existing SDL code. This commit merely makes it possible to explicitly select the SDL backend ("gl" alone uses SDL only if the X11 and win32 backends are not available, while the new "gl_sdl" always forces use of SDL). Also disable YUV conversion method autodetection when SDL is used. This gets rid of a temporary window that appears for a moment and is immediately closed again. SDL can't deal with the VOFLAG_HIDDEN flag, which is needed to create an invisible GL context (when the autodetection is run, the video size isn't yet known to the VO, and creating a window then resizing would cause problems with window placement). Instead always pick the fragment program method by default (yuv=2). This change affects the normal "gl" VO too if it chooses the SDL backend.
Diffstat (limited to 'libvo/vo_gl.c')
-rw-r--r--libvo/vo_gl.c50
1 files changed, 41 insertions, 9 deletions
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index 1a5884c9a6..abea7aeb30 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -1270,13 +1270,12 @@ static void uninit(struct vo *vo)
p->gl = NULL;
}
-static int preinit_internal(struct vo *vo, const char *arg, int allow_sw)
+static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
+ enum MPGLType gltype)
{
struct gl_priv *p = talloc_zero(vo, struct gl_priv);
vo->priv = p;
- enum MPGLType gltype = GLTYPE_AUTO;
-
*p = (struct gl_priv) {
.many_fmts = 1,
.use_osd = -1,
@@ -1412,6 +1411,14 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw)
if (!p->glctx)
goto err_out;
p->gl = p->glctx->gl;
+
+ if (p->glctx->type == GLTYPE_SDL && p->use_yuv == -1) {
+ // Apparently it's not possible to implement VOFLAG_HIDDEN on SDL 1.2,
+ // so don't do autodetection. Use a sufficiently useful and safe YUV
+ // conversion mode.
+ p->use_yuv = YUV_CONVERSION_FRAGMENT;
+ }
+
if (p->use_yuv == -1 || !allow_sw) {
if (create_window(vo, 320, 200, VOFLAG_HIDDEN, NULL) < 0)
goto err_out;
@@ -1444,12 +1451,7 @@ err_out:
static int preinit(struct vo *vo, const char *arg)
{
- return preinit_internal(vo, arg, 1);
-}
-
-static int preinit_nosw(struct vo *vo, const char *arg)
-{
- return preinit_internal(vo, arg, 0);
+ return preinit_internal(vo, arg, 1, GLTYPE_AUTO);
}
static int control(struct vo *vo, uint32_t request, void *data)
@@ -1564,6 +1566,11 @@ const struct vo_driver video_out_gl = {
.uninit = uninit,
};
+static int preinit_nosw(struct vo *vo, const char *arg)
+{
+ return preinit_internal(vo, arg, 0, GLTYPE_AUTO);
+}
+
const struct vo_driver video_out_gl_nosw =
{
.is_new = true,
@@ -1582,3 +1589,28 @@ const struct vo_driver video_out_gl_nosw =
.check_events = check_events,
.uninit = uninit,
};
+
+#ifdef CONFIG_GL_SDL
+static int preinit_sdl(struct vo *vo, const char *arg)
+{
+ return preinit_internal(vo, arg, 1, GLTYPE_SDL);
+}
+
+const struct vo_driver video_out_gl_sdl = {
+ .is_new = true,
+ .info = &(const vo_info_t) {
+ "OpenGL with SDL",
+ "gl_sdl",
+ "Reimar Doeffinger <Reimar.Doeffinger@gmx.de>",
+ ""
+ },
+ .preinit = preinit_sdl,
+ .config = config,
+ .control = control,
+ .draw_slice = draw_slice,
+ .draw_osd = draw_osd,
+ .flip_page = flip_page,
+ .check_events = check_events,
+ .uninit = uninit,
+};
+#endif