[vlc-devel] [PATCH 13/15] opengl: use the projection mode from the display configuration
Steve Lhomme
robux4 at videolabs.io
Mon Nov 7 10:52:02 CET 2016
only auto, flat, sphere, cubemap are currently supported
--
replaces https://patches.videolan.org/patch/14435/ only using values for sphere/cubemap
replaces https://patches.videolan.org/patch/14462/
* rename vlc_viewpoint to vlc_viewpoint_t
* rename projection_mode to vout_projection_mode_t
* rename PROJECTION_XXX to VOUT_PROJECTION_XXX
* vout_display_opengl_SetProjection() returns the mode in use or AUTO
---
modules/video_output/gl.c | 14 ++++++++
modules/video_output/ios2.m | 14 ++++++++
modules/video_output/macosx.m | 14 ++++++++
modules/video_output/opengl.c | 69 ++++++++++++++++++++++++++++++++----
modules/video_output/opengl.h | 2 ++
modules/video_output/win32/glwin32.c | 14 ++++++++
modules/video_output/xcb/glx.c | 14 ++++++++
7 files changed, 135 insertions(+), 6 deletions(-)
diff --git a/modules/video_output/gl.c b/modules/video_output/gl.c
index 34988c0..ee35a3c 100644
--- a/modules/video_output/gl.c
+++ b/modules/video_output/gl.c
@@ -255,6 +255,20 @@ static int Control (vout_display_t *vd, int query, va_list ap)
vout_display_opengl_SetViewpoint(sys->vgl, &p_cfg->viewpoint);
return VLC_SUCCESS;
}
+ case VOUT_DISPLAY_CHANGE_PROJECTION:
+ {
+ const vout_display_cfg_t *p_cfg = va_arg (ap, const vout_display_cfg_t *);
+ vout_projection_mode_t p =
+ vout_display_opengl_SetProjection( sys->vgl, p_cfg->projection);
+
+ if ( p == VOUT_PROJECTION_AUTO )
+ {
+ msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
+ return VLC_EBADVAR;
+ }
+ vd->projection = p;
+ return VLC_SUCCESS;
+ }
default:
msg_Err (vd, "Unknown request %d", query);
}
diff --git a/modules/video_output/ios2.m b/modules/video_output/ios2.m
index 9c11d77..b26f6a0 100644
--- a/modules/video_output/ios2.m
+++ b/modules/video_output/ios2.m
@@ -431,6 +431,20 @@ static int Control(vout_display_t *vd, int query, va_list ap)
vout_display_opengl_SetViewpoint(sys->vgl, &p_cfg->viewpoint);
return VLC_SUCCESS;
}
+ case VOUT_DISPLAY_CHANGE_PROJECTION:
+ {
+ const vout_display_cfg_t *p_cfg = va_arg (ap, const vout_display_cfg_t *);
+ vout_projection_mode_t p =
+ vout_display_opengl_SetProjection( sys->vgl, p_cfg->projection);
+
+ if ( p == VOUT_PROJECTION_AUTO )
+ {
+ msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
+ return VLC_EBADVAR;
+ }
+ vd->projection = p;
+ return VLC_SUCCESS;
+ }
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable ();
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 7e96709..ffa2e50 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -439,6 +439,20 @@ static int Control (vout_display_t *vd, int query, va_list ap)
vout_display_opengl_SetViewpoint(sys->vgl, &p_cfg->viewpoint);
return VLC_SUCCESS;
}
+ case VOUT_DISPLAY_CHANGE_PROJECTION:
+ {
+ const vout_display_cfg_t *p_cfg = va_arg (ap, const vout_display_cfg_t *);
+ vout_projection_mode_t p =
+ vout_display_opengl_SetProjection( sys->vgl, p_cfg->projection);
+
+ if ( p == VOUT_PROJECTION_AUTO )
+ {
+ msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
+ return VLC_EBADVAR;
+ }
+ vd->projection = p;
+ return VLC_SUCCESS;
+ }
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable ();
diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c
index 29f4980..058743b 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;
+ vout_projection_mode_t projection;
int tex_target;
int tex_format;
@@ -781,6 +782,25 @@ void vout_display_opengl_Delete(vout_display_opengl_t *vgl)
free(vgl);
}
+static vout_projection_mode_t vout_display_projection(vout_display_opengl_t *vgl)
+{
+ if (vgl->projection == VOUT_PROJECTION_AUTO)
+ {
+ switch (vgl->fmt.projection_mode)
+ {
+ case PROJECTION_MODE_RECTANGULAR:
+ return VOUT_PROJECTION_FLAT;
+ case PROJECTION_MODE_EQUIRECTANGULAR:
+ return VOUT_PROJECTION_SPHERE;
+ case PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD:
+ return VOUT_PROJECTION_CUBEMAP;
+ default:
+ break;
+ }
+ }
+ return vgl->projection;
+}
+
void vout_display_opengl_SetViewpoint(vout_display_opengl_t *vgl, const vlc_viewpoint_t *p_viewpoint)
{
vgl->f_teta = p_viewpoint->yaw - (float) M_PI / 2;
@@ -788,6 +808,43 @@ void vout_display_opengl_SetViewpoint(vout_display_opengl_t *vgl, const vlc_view
vgl->f_roll = p_viewpoint->roll;
}
+vout_projection_mode_t vout_display_opengl_SetProjection( vout_display_opengl_t *vgl,
+ vout_projection_mode_t proj_mode)
+{
+ switch (proj_mode)
+ {
+ case VOUT_PROJECTION_AUTO:
+ case VOUT_PROJECTION_FLAT:
+ case VOUT_PROJECTION_SPHERE:
+ case VOUT_PROJECTION_CUBEMAP:
+ if (proj_mode != VOUT_PROJECTION_AUTO)
+ vgl->projection = proj_mode;
+ else
+ {
+ switch (vgl->fmt.projection_mode)
+ {
+ case PROJECTION_MODE_RECTANGULAR:
+ vgl->projection = VOUT_PROJECTION_FLAT;
+ break;
+ case PROJECTION_MODE_EQUIRECTANGULAR:
+ vgl->projection = VOUT_PROJECTION_SPHERE;
+ break;
+ case PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD:
+ vgl->projection = VOUT_PROJECTION_CUBEMAP;
+ break;
+ default:
+ vgl->projection = VOUT_PROJECTION_FLAT;
+ break;
+ }
+ }
+ vlc_viewpoint_t viewpoint = {};
+ vout_display_opengl_SetViewpoint( vgl, &viewpoint );
+ return vgl->projection;
+ default:
+ return VOUT_PROJECTION_AUTO;
+ }
+}
+
picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned requested_count)
{
if (vgl->pool)
@@ -1505,21 +1562,22 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
unsigned nbVertices, nbIndices;
int i_ret;
- switch (vgl->fmt.projection_mode)
+ const vout_projection_mode_t projection = vout_display_projection(vgl);
+ switch (projection)
{
- case PROJECTION_MODE_RECTANGULAR:
+ case VOUT_PROJECTION_FLAT:
i_ret = BuildRectangle(vgl->chroma->plane_count,
&vertexCoord, &textureCoord, &nbVertices,
&indices, &nbIndices,
left, top, right, bottom);
break;
- case PROJECTION_MODE_EQUIRECTANGULAR:
+ case VOUT_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 VOUT_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,
@@ -1541,8 +1599,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 == VOUT_PROJECTION_SPHERE || projection == VOUT_PROJECTION_CUBEMAP)
{
float sar = (float) 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 2096309..969aa6d 100644
--- a/modules/video_output/opengl.h
+++ b/modules/video_output/opengl.h
@@ -98,6 +98,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*);
+vout_projection_mode_t vout_display_opengl_SetProjection(vout_display_opengl_t *,
+ vout_projection_mode_t);
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 ba2c967..9e6e161 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -157,6 +157,20 @@ static int Control(vout_display_t *vd, int query, va_list args)
vout_display_opengl_SetViewpoint(sys->vgl, &p_cfg->viewpoint);
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 *);
+ vout_projection_mode_t p =
+ vout_display_opengl_SetProjection( sys->vgl, p_cfg->projection );
+
+ if ( p == VOUT_PROJECTION_AUTO )
+ {
+ msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
+ return VLC_EBADVAR;
+ }
+ vd->projection = p;
+ return VLC_SUCCESS;
+ }
return CommonControl(vd, query, args);
}
diff --git a/modules/video_output/xcb/glx.c b/modules/video_output/xcb/glx.c
index f545e9f..aa3d7ff 100644
--- a/modules/video_output/xcb/glx.c
+++ b/modules/video_output/xcb/glx.c
@@ -253,6 +253,20 @@ static int Control (vout_display_t *vd, int query, va_list ap)
vout_display_opengl_SetViewpoint(sys->vgl, &p_cfg->viewpoint);
return VLC_SUCCESS;
}
+ case VOUT_DISPLAY_CHANGE_PROJECTION:
+ {
+ const vout_display_cfg_t *p_cfg = va_arg (ap, const vout_display_cfg_t *);
+ vout_projection_mode_t p =
+ vout_display_opengl_SetProjection( sys->vgl, p_cfg->projection );
+
+ if ( p == VOUT_PROJECTION_AUTO )
+ {
+ msg_Warn(vd, "Failed to set the projection type %d", p_cfg->projection);
+ return VLC_EBADVAR;
+ }
+ vd->projection = p;
+ return VLC_SUCCESS;
+ }
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable ();
--
2.10.1
More information about the vlc-devel
mailing list