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

Steve Lhomme robux4 at videolabs.io
Wed Sep 14 16:37:51 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 53e8dd9..0221f28 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
@@ -260,7 +262,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 b58f444..17eb034 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 {
@@ -462,7 +464,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 296909a..3d3f90e 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 ()
 
 /**
@@ -440,7 +442,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 1bcbaec..3387c2d 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;
@@ -813,7 +814,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)
     {
@@ -822,6 +823,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;
@@ -1259,11 +1261,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;
@@ -1558,7 +1564,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 0d8b31e..9a5f8c6 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()
 
 /*****************************************************************************
@@ -162,7 +164,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 143ac14..680c334 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
@@ -258,7 +260,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.7.2.windows.1



More information about the vlc-devel mailing list