[vlc-devel] [PATCH 03/15] opengl: handle the viewpoint changes when rendering
Steve Lhomme
robux4 at videolabs.io
Fri Nov 4 18:08:46 CET 2016
---
modules/video_output/gl.c | 6 ++++++
modules/video_output/opengl.c | 23 ++++++++++++++++++++---
modules/video_output/opengl.h | 3 +++
3 files changed, 29 insertions(+), 3 deletions(-)
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 b79bb13..aee96bd 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;
};
@@ -692,9 +693,12 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
if (vgl->fmt.projection_mode == PROJECTION_MODE_EQUIRECTANGULAR
|| vgl->fmt.projection_mode == PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD)
{
- vgl->f_teta = vgl->fmt.f_pose_roll_degrees / 180. * M_PI;
- vgl->f_phi = vgl->fmt.f_pose_yaw_degrees / 180. * M_PI;
- vgl->f_teta -= M_PI/2;
+ vlc_viewpoint_t viewpoint = {
+ .f_yaw = (float) vgl->fmt.f_pose_yaw_degrees / 180. * M_PI,
+ .f_pitch = (float) vgl->fmt.f_pose_pitch_degrees / 180. * M_PI,
+ .f_roll = (float) vgl->fmt.f_pose_roll_degrees / 180. * M_PI,
+ };
+ vout_display_opengl_SetViewpoint( vgl, &viewpoint );
}
/* */
@@ -777,6 +781,19 @@ void vout_display_opengl_Delete(vout_display_opengl_t *vgl)
free(vgl);
}
+void vout_display_opengl_SetViewpoint(vout_display_opengl_t *vgl, const vlc_viewpoint_t *p_viewpoint)
+{
+ vgl->f_teta = p_viewpoint->f_yaw - M_PI / 2;
+ 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..2096309 100644
--- a/modules/video_output/opengl.h
+++ b/modules/video_output/opengl.h
@@ -32,6 +32,7 @@
#include <vlc_common.h>
#include <vlc_picture_pool.h>
#include <vlc_opengl.h>
+#include <vlc_vout.h>
/* Change USE_OPENGL_ES value to set the OpenGL ES version (1, 2) you want to use
* A value of 0 will activate normal OpenGL */
@@ -96,6 +97,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_t*);
+
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,
--
2.10.1
More information about the vlc-devel
mailing list