[vlc-devel] [PATCH 4/8] opengl: handle the viewpoint changes when rendering

Steve Lhomme robux4 at videolabs.io
Thu Sep 8 17:35:31 CEST 2016


---
 modules/video_output/gl.c     |  7 +++++++
 modules/video_output/opengl.c | 19 +++++++++++++++++++
 modules/video_output/opengl.h |  3 +++
 3 files changed, 29 insertions(+)

diff --git a/modules/video_output/gl.c b/modules/video_output/gl.c
index 082aa78..4bdeddd 100644
--- a/modules/video_output/gl.c
+++ b/modules/video_output/gl.c
@@ -249,6 +249,13 @@ 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 video_format_t *src = va_arg (ap, const video_format_t *);
+        vout_display_opengl_SetViewpoint(sys->vgl, src->f_pose_yaw_degrees,
+                                         src->f_pose_pitch_degrees, src->f_pose_roll_degrees);
+        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..ff049a1 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,24 @@ void vout_display_opengl_Delete(vout_display_opengl_t *vgl)
     free(vgl);
 }
 
+void vout_display_opengl_SetViewpoint(vout_display_opengl_t *vgl,
+                                      float yaw, float pitch, float roll)
+{
+    if ( vgl->projection == PROJECTION_FLAT ||
+         (vgl->projection == PROJECTION_AUTO && vgl->fmt.projection_mode == PROJECTION_MODE_RECTANGULAR))
+        return;
+
+    vgl->f_teta = yaw;
+    if (vgl->f_teta < -M_PI)
+        vgl->f_teta = M_PI;
+    vgl->f_phi = pitch;
+    if (vgl->f_phi < -M_PI / 2)
+        vgl->f_phi = -M_PI / 2;
+    vgl->f_roll = 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..9e37f61 100644
--- a/modules/video_output/opengl.h
+++ b/modules/video_output/opengl.h
@@ -96,6 +96,9 @@ 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,
+                                      float yaw, float pitch, float roll);
+
 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.8.2



More information about the vlc-devel mailing list