[vlc-devel] [PATCH 7/7] opengl: add an option to changed the number of slices for spherical projections

Steve Lhomme robux4 at videolabs.io
Mon Sep 12 14:01:37 CEST 2016


default is now 50
---
 modules/video_output/gl.c            |  5 ++++-
 modules/video_output/ios2.m          |  5 ++++-
 modules/video_output/macosx.m        |  5 ++++-
 modules/video_output/opengl.c        | 17 ++++++++++++-----
 modules/video_output/opengl.h        |  5 ++++-
 modules/video_output/win32/glwin32.c |  5 ++++-
 modules/video_output/xcb/glx.c       |  5 ++++-
 7 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/modules/video_output/gl.c b/modules/video_output/gl.c
index 090d47d..b7c00be 100644
--- a/modules/video_output/gl.c
+++ b/modules/video_output/gl.c
@@ -78,6 +78,8 @@ vlc_module_begin ()
     add_module ("gl", "opengl", NULL,
                 GL_TEXT, PROVIDER_LONGTEXT, true)
 #endif
+    add_integer("gl-projection-slices", 0, GL_PROJECTION_SLICES_TEXT, GL_PROJECTION_SLICES_LONGTEXT, true)
+
 vlc_module_end ()
 
 struct vout_display_sys_t
@@ -259,7 +261,8 @@ static int Control (vout_display_t *vd, int query, va_list ap)
       case VOUT_DISPLAY_CHANGE_PROJECTION:
       {
           const vout_display_cfg_t *p_cfg = va_arg (ap, const vout_display_cfg_t *);
-          int res = vout_display_opengl_SetProjection(sys->vgl, p_cfg->projection);
+          int res = vout_display_opengl_SetProjection(sys->vgl, p_cfg->projection,
+                                                      var_InheritInteger(vd, "gl-projection-slices"));
 
           if (res != VLC_SUCCESS )
               msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
diff --git a/modules/video_output/ios2.m b/modules/video_output/ios2.m
index 04cbf18..09e2bb4 100644
--- a/modules/video_output/ios2.m
+++ b/modules/video_output/ios2.m
@@ -154,6 +154,8 @@ vlc_module_begin ()
     set_callbacks(Open, Close)
 
     add_shortcut("vout_ios2")
+
+    add_integer("gl-projection-slices", 0, GL_PROJECTION_SLICES_TEXT, GL_PROJECTION_SLICES_LONGTEXT, true)
 vlc_module_end ()
 
 @interface VLCOpenGLES2VideoView : UIView {
@@ -461,7 +463,8 @@ static int Control(vout_display_t *vd, int query, va_list ap)
         case VOUT_DISPLAY_CHANGE_PROJECTION:
         {
             const vout_display_cfg_t *p_cfg = va_arg (args, const vout_display_cfg_t *);
-            int res = vout_display_opengl_SetProjection(sys->vgl, p_cfg->projection);
+            int res = vout_display_opengl_SetProjection(sys->vgl, p_cfg->projection,
+                                                        var_InheritInteger(vd, "gl-projection-slices"));
 
             if (res != VLC_SUCCESS )
                 msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 9f2079d..e92109b 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -81,6 +81,8 @@ vlc_module_begin ()
     set_callbacks (Open, Close)
 
     add_shortcut ("macosx", "vout_macosx")
+
+    add_integer("gl-projection-slices", 0, GL_PROJECTION_SLICES_TEXT, GL_PROJECTION_SLICES_LONGTEXT, true)
 vlc_module_end ()
 
 /**
@@ -439,7 +441,8 @@ static int Control (vout_display_t *vd, int query, va_list ap)
             case VOUT_DISPLAY_CHANGE_PROJECTION:
             {
                 const vout_display_cfg_t *p_cfg = va_arg (args, const vout_display_cfg_t *);
-                int res = vout_display_opengl_SetProjection(sys->vgl, p_cfg->projection);
+                int res = vout_display_opengl_SetProjection(sys->vgl, p_cfg->projection,
+                                                            var_InheritInteger(vd, "gl-projection-slices"));
 
                 if (res != VLC_SUCCESS )
                     msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c
index 4d31e5c..55506a5 100644
--- a/modules/video_output/opengl.c
+++ b/modules/video_output/opengl.c
@@ -121,6 +121,7 @@ struct vout_display_opengl_t {
     video_format_t fmt;
     const vlc_chroma_description_t *chroma;
     projection_mode projection;
+    int projection_slices;
 
     int        tex_target;
     int        tex_format;
@@ -796,7 +797,7 @@ void vout_display_opengl_SetViewpoint(vout_display_opengl_t *vgl,
         vgl->f_roll = -M_PI / 2;
 }
 
-int vout_display_opengl_SetProjection(vout_display_opengl_t *vgl, projection_mode proj_mode)
+int vout_display_opengl_SetProjection(vout_display_opengl_t *vgl, projection_mode proj_mode, int projection_slices)
 {
     switch (proj_mode)
     {
@@ -805,6 +806,7 @@ int vout_display_opengl_SetProjection(vout_display_opengl_t *vgl, projection_mod
     case PROJECTION_SPHERE:
     case PROJECTION_CUBEMAP:
         vgl->projection = proj_mode;
+        vgl->projection_slices = projection_slices;
         return VLC_SUCCESS;
     default:
         return VLC_EBADVAR;
@@ -1242,11 +1244,15 @@ static void DrawWithoutShaders(vout_display_opengl_t *vgl,
 static int BuildSphere(unsigned nbPlanes,
                         GLfloat **vertexCoord, GLfloat **textureCoord, unsigned *nbVertices,
                         GLushort **indices, unsigned *nbIndices,
-                        float *left, float *top, float *right, float *bottom)
+                        float *left, float *top, float *right, float *bottom,
+                        unsigned nbLatBands, unsigned nbLonBands)
 {
     float radius = 1;
-    unsigned nbLatBands = 128;
-    unsigned nbLonBands = 128;
+
+    if (nbLatBands == 0)
+        nbLatBands = 50;
+    if (nbLonBands == 0)
+        nbLonBands = 50;
 
     *nbVertices = (nbLatBands + 1) * (nbLonBands + 1);
     *nbIndices = nbLatBands * nbLonBands * 3 * 2;
@@ -1557,7 +1563,8 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
         i_ret = BuildSphere(vgl->chroma->plane_count,
                             &vertexCoord, &textureCoord, &nbVertices,
                             &indices, &nbIndices,
-                            left, top, right, bottom);
+                            left, top, right, bottom,
+                            vgl->projection_slices, vgl->projection_slices);
         break;
     case PROJECTION_CUBEMAP:
         i_ret = BuildCube(vgl->chroma->plane_count,
diff --git a/modules/video_output/opengl.h b/modules/video_output/opengl.h
index 4a9b34b..61cf459 100644
--- a/modules/video_output/opengl.h
+++ b/modules/video_output/opengl.h
@@ -68,6 +68,9 @@
 # endif
 #endif
 
+#define GL_PROJECTION_SLICES_TEXT     N_("Projection Slices")
+#define GL_PROJECTION_SLICES_LONGTEXT N_("Amount of slices in the projection sphere (0 = default).")
+
 static const vlc_fourcc_t gl_subpicture_chromas[] = {
     VLC_CODEC_RGBA,
     0
@@ -99,7 +102,7 @@ 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_SetProjection(vout_display_opengl_t *vgl, projection_mode);
+int vout_display_opengl_SetProjection(vout_display_opengl_t *vgl, projection_mode, int);
 
 int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
                                 picture_t *picture, subpicture_t *subpicture);
diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c
index 8a2cb54..e724b3a 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -55,6 +55,8 @@ vlc_module_begin()
     set_capability("vout display", 220)
     add_shortcut("glwin32", "opengl")
     set_callbacks(Open, Close)
+
+    add_integer("gl-projection-slices", 0, GL_PROJECTION_SLICES_TEXT, GL_PROJECTION_SLICES_LONGTEXT, true)
 vlc_module_end()
 
 /*****************************************************************************
@@ -161,7 +163,8 @@ static int Control(vout_display_t *vd, int query, va_list args)
     else if (query == VOUT_DISPLAY_CHANGE_PROJECTION)
     {
         const vout_display_cfg_t *p_cfg = va_arg (args, const vout_display_cfg_t *);
-        int res = vout_display_opengl_SetProjection(sys->vgl, p_cfg->projection);
+        int res = vout_display_opengl_SetProjection(sys->vgl, p_cfg->projection,
+                                                    var_InheritInteger(vd, "gl-projection-slices"));
 
         if (res != VLC_SUCCESS )
             msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
diff --git a/modules/video_output/xcb/glx.c b/modules/video_output/xcb/glx.c
index cf4710d..b83ca35 100644
--- a/modules/video_output/xcb/glx.c
+++ b/modules/video_output/xcb/glx.c
@@ -53,6 +53,8 @@ vlc_module_begin ()
     set_callbacks (Open, Close)
 
     add_shortcut ("xcb-glx", "glx", "opengl", "xid")
+
+    add_integer("gl-projection-slices", 0, GL_PROJECTION_SLICES_TEXT, GL_PROJECTION_SLICES_LONGTEXT, true)
 vlc_module_end ()
 
 struct vout_display_sys_t
@@ -257,7 +259,8 @@ static int Control (vout_display_t *vd, int query, va_list ap)
     case VOUT_DISPLAY_CHANGE_PROJECTION:
     {
         const vout_display_cfg_t *p_cfg = va_arg (args, const vout_display_cfg_t *);
-        int res = vout_display_opengl_SetProjection(sys->vgl, p_cfg->projection);
+        int res = vout_display_opengl_SetProjection(sys->vgl, p_cfg->projection,
+                                                    var_InheritInteger(vd, "gl-projection-slices"));
 
         if (res != VLC_SUCCESS )
             msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
-- 
2.8.2



More information about the vlc-devel mailing list