/*****************************************************************************
* Copyright © 2010-2011 Rémi Denis-Courmont
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- ****************************************************************************/
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#include "opengl.h"
/* Plugin callbacks */
-static int OpenGL (vlc_object_t *);
-static int OpenGLES2 (vlc_object_t *);
-static int OpenGLES (vlc_object_t *);
+static int Open (vlc_object_t *);
static void Close (vlc_object_t *);
#define GL_TEXT N_("OpenGL extension")
"Extension through which to use the Open Graphics Library (OpenGL).")
vlc_module_begin ()
- set_shortname (N_("OpenGL"))
- set_description (N_("Open Graphics Library video output"))
- set_category (CAT_VIDEO)
- set_subcategory (SUBCAT_VIDEO_VOUT)
- set_capability ("vout display", /*170*/0)
- set_callbacks (OpenGL, Close)
- add_shortcut ("opengl", "gl")
- add_module ("gl", "opengl", NULL, NULL,
- GL_TEXT, PROVIDER_LONGTEXT, true)
-
- add_submodule ()
+#if USE_OPENGL_ES == 2
+# define API VLC_OPENGL_ES2
+# define MODULE_VARNAME "gles2"
set_shortname (N_("OpenGL ES2"))
set_description (N_("OpenGL for Embedded Systems 2 video output"))
set_capability ("vout display", /*165*/0)
- set_callbacks (OpenGLES2, Close)
+ set_callbacks (Open, Close)
add_shortcut ("opengles2", "gles2")
- add_module ("gles2", "opengl es2", NULL, NULL,
+ add_module ("gles2", "opengl es2", NULL,
GLES2_TEXT, PROVIDER_LONGTEXT, true)
- add_submodule ()
+#elif USE_OPENGL_ES == 1
+# define API VLC_OPENGL_ES
+# define MODULE_VARNAME "gles"
set_shortname (N_("OpenGL ES"))
set_description (N_("OpenGL for Embedded Systems video output"))
set_capability ("vout display", /*160*/0)
- set_callbacks (OpenGLES, Close)
+ set_callbacks (Open, Close)
add_shortcut ("opengles", "gles")
- add_module ("gles", "opengl es", NULL, NULL,
+ add_module ("gles", "opengl es", NULL,
GLES_TEXT, PROVIDER_LONGTEXT, true)
-
+#else
+# define API VLC_OPENGL
+# define MODULE_VARNAME "gl"
+ set_shortname (N_("OpenGL"))
+ set_description (N_("OpenGL video output (experimental)"))
+ set_category (CAT_VIDEO)
+ set_subcategory (SUBCAT_VIDEO_VOUT)
+ set_capability ("vout display", /*170*/0)
+ set_callbacks (Open, Close)
+ add_shortcut ("opengl", "gl")
+ add_module ("gl", "opengl", NULL,
+ GL_TEXT, PROVIDER_LONGTEXT, true)
+#endif
vlc_module_end ()
struct vout_display_sys_t
{
- vout_display_opengl_t vgl;
-
- vout_window_t *window;
+ vout_display_opengl_t *vgl;
vlc_gl_t *gl;
picture_pool_t *pool;
};
static vout_window_t *MakeWindow (vout_display_t *vd)
{
- vout_window_cfg_t wnd_cfg;
-
- memset (&wnd_cfg, 0, sizeof (wnd_cfg));
- wnd_cfg.type = VOUT_WINDOW_TYPE_NATIVE;
- wnd_cfg.x = var_InheritInteger (vd, "video-x");
- wnd_cfg.y = var_InheritInteger (vd, "video-y");
- wnd_cfg.width = vd->cfg->display.width;
- wnd_cfg.height = vd->cfg->display.height;
-
- vout_window_t *wnd = vout_display_NewWindow (vd, &wnd_cfg);
- if (wnd == NULL)
- msg_Err (vd, "parent window not available");
- return wnd;
+ vout_window_cfg_t cfg = {
+ .x = var_InheritInteger (vd, "video-x"),
+ .y = var_InheritInteger (vd, "video-y"),
+ .width = vd->cfg->display.width,
+ .height = vd->cfg->display.height,
+ };
+ vout_window_t *wnd;
+
+#if defined(_WIN32)
+ cfg.type = VOUT_WINDOW_TYPE_HWND;
+#elif defined(__ANDROID__)
+ cfg.type = VOUT_WINDOW_TYPE_ANDROID_NATIVE;
+#else
+ cfg.type = VOUT_WINDOW_TYPE_XID;
+#endif
+
+ wnd = vout_display_NewWindow (vd, &cfg);
+ if (wnd != NULL)
+ return wnd;
+
+ msg_Err (vd, "parent window not available");
+ return NULL;
}
/**
* Allocates a surface and an OpenGL context for video output.
*/
-static int Open (vlc_object_t *obj, unsigned api, const char *name)
+static int Open (vlc_object_t *obj)
{
vout_display_t *vd = (vout_display_t *)obj;
vout_display_sys_t *sys = malloc (sizeof (*sys));
sys->gl = NULL;
sys->pool = NULL;
- sys->window = MakeWindow (vd);
- if (sys->window == NULL)
+ vout_window_t *surface = MakeWindow (vd);
+ if (surface == NULL)
goto error;
- sys->gl = vlc_gl_Create (sys->window, api, name);
+ sys->gl = vlc_gl_Create (surface, API, "$" MODULE_VARNAME);
if (sys->gl == NULL)
goto error;
+ /* Initialize video display */
+ const vlc_fourcc_t *spu_chromas;
+
if (vlc_gl_MakeCurrent (sys->gl))
goto error;
- /* Initialize video display */
- if (vout_display_opengl_Init (&sys->vgl, &vd->fmt, sys->gl))
+ sys->vgl = vout_display_opengl_New (&vd->fmt, &spu_chromas, sys->gl);
+ vlc_gl_ReleaseCurrent (sys->gl);
+
+ if (sys->vgl == NULL)
goto error;
+ bool fs = vd->cfg->is_fullscreen;
+ if (vout_window_SetFullScreen (sys->gl->surface, fs))
+ fs = false;
+ vout_display_SendEventFullscreen (vd, fs);
+
vd->sys = sys;
vd->info.has_pictures_invalid = false;
vd->info.has_event_thread = false;
+ vd->info.subpicture_chromas = spu_chromas;
vd->pool = Pool;
vd->prepare = PictureRender;
vd->display = PictureDisplay;
error:
if (sys->gl != NULL)
vlc_gl_Destroy (sys->gl);
- if (sys->window != NULL)
- vout_display_DeleteWindow (vd, sys->window);
+ if (surface != NULL)
+ vout_display_DeleteWindow (vd, surface);
free (sys);
return VLC_EGENERIC;
}
-static int OpenGL (vlc_object_t *obj)
-{
- return Open (obj, VLC_OPENGL, "$gl");
-}
-
-static int OpenGLES2 (vlc_object_t *obj)
-{
- return Open (obj, VLC_OPENGL_ES2, "$gles2");
-}
-
-static int OpenGLES (vlc_object_t *obj)
-{
- return Open (obj, VLC_OPENGL_ES2, "$gles");
-}
-
/**
* Destroys the OpenGL context.
*/
{
vout_display_t *vd = (vout_display_t *)obj;
vout_display_sys_t *sys = vd->sys;
+ vlc_gl_t *gl = sys->gl;
+ vout_window_t *surface = gl->surface;
+
+ vlc_gl_MakeCurrent (gl);
+ vout_display_opengl_Delete (sys->vgl);
+ vlc_gl_ReleaseCurrent (gl);
- vout_display_opengl_Clean (&sys->vgl);
- vlc_gl_Destroy (sys->gl);
- vout_display_DeleteWindow (vd, sys->window);
+ vlc_gl_Destroy (gl);
+ vout_display_DeleteWindow (vd, surface);
free (sys);
}
vout_display_sys_t *sys = vd->sys;
if (!sys->pool)
- sys->pool = vout_display_opengl_GetPool (&sys->vgl);
- (void) count;
+ {
+ vlc_gl_MakeCurrent (sys->gl);
+ sys->pool = vout_display_opengl_GetPool (sys->vgl, count);
+ vlc_gl_ReleaseCurrent (sys->gl);
+ }
return sys->pool;
}
{
vout_display_sys_t *sys = vd->sys;
- vout_display_opengl_Prepare (&sys->vgl, pic);
- (void)subpicture;
+ vlc_gl_MakeCurrent (sys->gl);
+ vout_display_opengl_Prepare (sys->vgl, pic, subpicture);
+ vlc_gl_ReleaseCurrent (sys->gl);
}
static void PictureDisplay (vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
{
vout_display_sys_t *sys = vd->sys;
- vout_display_opengl_Display (&sys->vgl, &vd->source);
+ vlc_gl_MakeCurrent (sys->gl);
+ vout_display_opengl_Display (sys->vgl, &vd->source);
+ vlc_gl_ReleaseCurrent (sys->gl);
+
picture_Release (pic);
- (void)subpicture;
+ (void) subpicture;
}
static int Control (vout_display_t *vd, int query, va_list ap)
#endif
case VOUT_DISPLAY_CHANGE_FULLSCREEN:
{
- const vout_display_cfg_t *cfg =
+ const vout_display_cfg_t *c =
va_arg (ap, const vout_display_cfg_t *);
- return vout_window_SetFullScreen (sys->window, cfg->is_fullscreen);
+ return vout_window_SetFullScreen (sys->gl->surface, c->is_fullscreen);
}
case VOUT_DISPLAY_CHANGE_WINDOW_STATE:
{
unsigned state = va_arg (ap, unsigned);
- return vout_window_SetState (sys->window, state);
+ return vout_window_SetState (sys->gl->surface, state);
}
case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
case VOUT_DISPLAY_CHANGE_ZOOM:
{
- const vout_display_cfg_t *cfg = va_arg (ap, const vout_display_cfg_t *);
+ const vout_display_cfg_t *c = va_arg (ap, const vout_display_cfg_t *);
const video_format_t *src = &vd->source;
- if (query == VOUT_DISPLAY_CHANGE_DISPLAY_SIZE)
+ if (query == VOUT_DISPLAY_CHANGE_DISPLAY_SIZE && va_arg (ap, int))
{
- bool force = false;
-
- force = va_arg (ap, int);
- if (force
- && (cfg->display.width != vd->cfg->display.width
- || cfg->display.height != vd->cfg->display.height)
- && vout_window_SetSize (sys->window,
- cfg->display.width, cfg->display.height))
- return VLC_EGENERIC;
+ vout_window_SetSize (sys->gl->surface,
+ c->display.width, c->display.height);
+ return VLC_EGENERIC;
}
vout_display_place_t place;
- vout_display_PlacePicture (&place, src, cfg, false);
- glViewport (0, 0, place.width, place.height);
+ vout_display_PlacePicture (&place, src, c, false);
+ vlc_gl_MakeCurrent (sys->gl);
+ glViewport (place.x, place.y, place.width, place.height);
+ vlc_gl_ReleaseCurrent (sys->gl);
return VLC_SUCCESS;
}
vout_display_place_t place;
vout_display_PlacePicture (&place, src, cfg, false);
- glViewport (0, 0, place.width, place.height);
+ vlc_gl_MakeCurrent (sys->gl);
+ glViewport (place.x, place.y, place.width, place.height);
+ vlc_gl_ReleaseCurrent (sys->gl);
return VLC_SUCCESS;
}