[vlc-devel] [PATCH 6/7] opengl: use the projection mode from the display configuration
Steve Lhomme
robux4 at videolabs.io
Wed Sep 14 16:37:50 CEST 2016
only auto, flat, sphere, cubemap are currently supported
--
replaces https://patches.videolan.org/patch/14435/ only using values for sphere/cubemap
---
modules/video_output/gl.c | 9 +++++++
modules/video_output/ios2.m | 9 +++++++
modules/video_output/macosx.m | 9 +++++++
modules/video_output/opengl.c | 47 +++++++++++++++++++++++++++++++-----
modules/video_output/opengl.h | 2 ++
modules/video_output/win32/glwin32.c | 9 +++++++
modules/video_output/xcb/glx.c | 9 +++++++
7 files changed, 88 insertions(+), 6 deletions(-)
diff --git a/modules/video_output/gl.c b/modules/video_output/gl.c
index 5c8a6b4..53e8dd9 100644
--- a/modules/video_output/gl.c
+++ b/modules/video_output/gl.c
@@ -257,6 +257,15 @@ static int Control (vout_display_t *vd, int query, va_list ap)
p_cfg->viewpoint.f_roll_degrees);
return VLC_SUCCESS;
}
+ 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);
+
+ if (res != VLC_SUCCESS )
+ msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
+ return res;
+ }
default:
msg_Err (vd, "Unknown request %d", query);
}
diff --git a/modules/video_output/ios2.m b/modules/video_output/ios2.m
index 780fab4..b58f444 100644
--- a/modules/video_output/ios2.m
+++ b/modules/video_output/ios2.m
@@ -459,6 +459,15 @@ static int Control(vout_display_t *vd, int query, va_list ap)
p_cfg->viewpoint.f_roll_degrees);
return VLC_SUCCESS;
}
+ 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);
+
+ if (res != VLC_SUCCESS )
+ msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
+ return res;
+ }
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable ();
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 8f33215..296909a 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -437,6 +437,15 @@ static int Control (vout_display_t *vd, int query, va_list ap)
p_cfg->viewpoint.f_roll_degrees);
return VLC_SUCCESS;
}
+ 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);
+
+ if (res != VLC_SUCCESS )
+ msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
+ return res;
+ }
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable ();
diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c
index c7ec5f6..1bcbaec 100644
--- a/modules/video_output/opengl.c
+++ b/modules/video_output/opengl.c
@@ -120,6 +120,7 @@ struct vout_display_opengl_t {
video_format_t fmt;
const vlc_chroma_description_t *chroma;
+ projection_mode projection;
int tex_target;
int tex_format;
@@ -777,6 +778,25 @@ 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,
float yaw, float pitch, float roll)
{
@@ -793,6 +813,21 @@ 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)
+{
+ switch (proj_mode)
+ {
+ case PROJECTION_AUTO:
+ case PROJECTION_FLAT:
+ case PROJECTION_SPHERE:
+ case PROJECTION_CUBEMAP:
+ vgl->projection = proj_mode;
+ return VLC_SUCCESS;
+ default:
+ return VLC_EBADVAR;
+ }
+}
+
picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned requested_count)
{
if (vgl->pool)
@@ -1510,21 +1545,22 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
unsigned nbVertices, nbIndices;
int i_ret;
- switch (vgl->fmt.projection_mode)
+ const projection_mode projection = vout_display_projection(vgl);
+ switch (projection)
{
- case PROJECTION_MODE_RECTANGULAR:
+ case PROJECTION_FLAT:
i_ret = BuildRectangle(vgl->chroma->plane_count,
&vertexCoord, &textureCoord, &nbVertices,
&indices, &nbIndices,
left, top, right, bottom);
break;
- case PROJECTION_MODE_EQUIRECTANGULAR:
+ case PROJECTION_SPHERE:
i_ret = BuildSphere(vgl->chroma->plane_count,
&vertexCoord, &textureCoord, &nbVertices,
&indices, &nbIndices,
left, top, right, bottom);
break;
- case PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD:
+ case PROJECTION_CUBEMAP:
i_ret = BuildCube(vgl->chroma->plane_count,
(float)vgl->fmt.i_cubemap_padding / vgl->fmt.i_width,
(float)vgl->fmt.i_cubemap_padding / vgl->fmt.i_height,
@@ -1546,8 +1582,7 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
orientationTransformMatrix(orientationMatrix, vgl->fmt.orientation);
- if (vgl->fmt.projection_mode == PROJECTION_MODE_EQUIRECTANGULAR
- || vgl->fmt.projection_mode == PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD)
+ if (projection == PROJECTION_SPHERE || projection == PROJECTION_CUBEMAP)
{
float sar = vgl->fmt.i_visible_width / vgl->fmt.i_visible_height;
getProjectionMatrix(sar, projectionMatrix);
diff --git a/modules/video_output/opengl.h b/modules/video_output/opengl.h
index 9e37f61..4a9b34b 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 */
@@ -98,6 +99,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_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 ee17e46..0d8b31e 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -159,6 +159,15 @@ static int Control(vout_display_t *vd, int query, va_list args)
p_cfg->viewpoint.f_roll_degrees);
return VLC_SUCCESS;
}
+ 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);
+
+ if (res != VLC_SUCCESS )
+ msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
+ return res;
+ }
return CommonControl(vd, query, args);
}
diff --git a/modules/video_output/xcb/glx.c b/modules/video_output/xcb/glx.c
index fb76dbd..143ac14 100644
--- a/modules/video_output/xcb/glx.c
+++ b/modules/video_output/xcb/glx.c
@@ -255,6 +255,15 @@ static int Control (vout_display_t *vd, int query, va_list ap)
p_cfg->viewpoint.f_roll_degrees);
return VLC_SUCCESS;
}
+ 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);
+
+ if (res != VLC_SUCCESS )
+ msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
+ return res;
+ }
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable ();
--
2.7.2.windows.1
More information about the vlc-devel
mailing list