1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-19 22:36:55 +00:00

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.
This commit is contained in:
wm4 2011-09-29 22:20:46 +02:00 committed by Uoti Urpala
parent 98b89d4aa7
commit bb8781a00a
2 changed files with 45 additions and 9 deletions

View File

@ -84,6 +84,7 @@ extern struct vo_driver video_out_vdpau;
extern struct vo_driver video_out_xv;
extern struct vo_driver video_out_gl_nosw;
extern struct vo_driver video_out_gl;
extern struct vo_driver video_out_gl_sdl;
extern struct vo_driver video_out_dga;
extern struct vo_driver video_out_sdl;
extern struct vo_driver video_out_3dfx;
@ -180,6 +181,9 @@ const struct vo_driver *video_out_drivers[] =
#ifdef CONFIG_GL
&video_out_gl,
#endif
#ifdef CONFIG_GL_SDL
&video_out_gl_sdl,
#endif
#ifdef CONFIG_DGA
&video_out_dga,
#endif

View File

@ -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