[vlc-devel] [PATCH 04/10] opengl: handle the viewpoint changes when rendering
Steve Lhomme
robux4 at videolabs.io
Fri Sep 16 18:00:30 CEST 2016
--
replaces https://patches.videolan.org/patch/14444/ by keeping the values even
if not used
replaces https://patches.videolan.org/patch/14456/ using vlc_viewpoint
---
modules/video_output/gl.c | 6 ++++++
modules/video_output/opengl.c | 35 +++++++++++++++++++++++++++++++++++
modules/video_output/opengl.h | 2 ++
3 files changed, 43 insertions(+)
diff --git a/modules/video_output/gl.c b/modules/video_output/gl.c
index 082aa78..34988c0 100644
--- a/modules/video_output/gl.c
+++ b/modules/video_output/gl.c
@@ -249,6 +249,12 @@ static int Control (vout_display_t *vd, int query, va_list ap)
vlc_gl_ReleaseCurrent (sys->gl);
return VLC_SUCCESS;
}
+ case VOUT_DISPLAY_CHANGE_VIEWPOINT:
+ {
+ const vout_display_cfg_t *p_cfg = va_arg (ap, const vout_display_cfg_t *);
+ vout_display_opengl_SetViewpoint(sys->vgl, &p_cfg->viewpoint);
+ return VLC_SUCCESS;
+ }
default:
msg_Err (vd, "Unknown request %d", query);
}
diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c
index 6017fdc..c1578b0 100644
--- a/modules/video_output/opengl.c
+++ b/modules/video_output/opengl.c
@@ -205,6 +205,7 @@ struct vout_display_opengl_t {
/* View point */
float f_teta;
float f_phi;
+ float f_roll;
float f_zoom;
};
@@ -776,6 +777,40 @@ void vout_display_opengl_Delete(vout_display_opengl_t *vgl)
free(vgl);
}
+static projection_mode vout_display_projection(vout_display_opengl_t *vgl)
+{
+ if (vgl->projection == PROJECTION_AUTO)
+ {
+ switch (vgl->fmt.projection_mode)
+ {
+ case PROJECTION_MODE_RECTANGULAR:
+ return PROJECTION_FLAT;
+ case PROJECTION_MODE_EQUIRECTANGULAR:
+ return PROJECTION_SPHERE;
+ case PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD:
+ return PROJECTION_CUBEMAP;
+ default:
+ break;
+ }
+ }
+ return vgl->projection;
+}
+
+void vout_display_opengl_SetViewpoint(vout_display_opengl_t *vgl, const vlc_viewpoint *p_viewpoint)
+{
+ const projection_mode proj_mode = vout_display_projection(vgl);
+
+ vgl->f_teta = p_viewpoint->f_yaw;
+ if (vgl->f_teta < -M_PI)
+ vgl->f_teta = M_PI;
+ vgl->f_phi = p_viewpoint->f_pitch;
+ if (vgl->f_phi < -M_PI / 2)
+ vgl->f_phi = -M_PI / 2;
+ vgl->f_roll = p_viewpoint->f_roll;
+ if (vgl->f_roll < -M_PI / 2)
+ vgl->f_roll = -M_PI / 2;
+}
+
picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned requested_count)
{
if (vgl->pool)
diff --git a/modules/video_output/opengl.h b/modules/video_output/opengl.h
index 4ae9400..31e332d 100644
--- a/modules/video_output/opengl.h
+++ b/modules/video_output/opengl.h
@@ -96,6 +96,8 @@ void vout_display_opengl_Delete(vout_display_opengl_t *vgl);
picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned);
+void vout_display_opengl_SetViewpoint(vout_display_opengl_t *vgl, const vlc_viewpoint*);
+
int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
picture_t *picture, subpicture_t *subpicture);
int vout_display_opengl_Display(vout_display_opengl_t *vgl,
More information about the vlc-devel
mailing list