[vlc-devel] [PATCH 07/16] opengl: pass the viewpoint zoom/field of view with the yaw/pitch/roll
Thomas Guillem
thomas at gllm.fr
Wed Nov 9 18:33:01 CET 2016
From: Steve Lhomme <robux4 at videolabs.io>
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
---
modules/video_output/opengl.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c
index b117455..43c2cf5 100644
--- a/modules/video_output/opengl.c
+++ b/modules/video_output/opengl.c
@@ -207,6 +207,7 @@ struct vout_display_opengl_t {
float f_teta;
float f_phi;
float f_roll;
+ float f_fov;
float f_zoom;
};
@@ -425,11 +426,19 @@ static void BuildXYZFragmentShader(vout_display_opengl_t *vgl,
#endif
static int
-SetViewpoint(vout_display_opengl_t *vgl, float f_teta, float f_phi, float f_roll)
+SetViewpoint(vout_display_opengl_t *vgl, float f_teta, float f_phi, float f_roll,
+ float f_fov, float f_zoom)
{
+ if (f_fov + 1.14f > (float) M_PI -0.001f)
+ return VLC_EBADVAR;
+ if (f_fov + 1.14f < 0.001f)
+ return VLC_EBADVAR;
vgl->f_teta = f_teta - (float) M_PI / 2;
vgl->f_phi = f_phi;
vgl->f_roll = f_roll;
+ vgl->f_fov = f_fov + 1.14f;
+ vgl->f_zoom = f_zoom;
+
return VLC_SUCCESS;
}
@@ -705,7 +714,8 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
{
SetViewpoint(vgl, vgl->fmt.f_pose_yaw_degrees / 180.f * (float) M_PI,
vgl->fmt.f_pose_pitch_degrees / 180.f * (float) M_PI,
- vgl->fmt.f_pose_roll_degrees / 180.f * (float) M_PI);
+ vgl->fmt.f_pose_roll_degrees / 180.f * (float) M_PI,
+ 0.f, 0.f);
}
/* */
@@ -792,7 +802,9 @@ int vout_display_opengl_SetViewpoint(vout_display_opengl_t *vgl, const vlc_viewp
{
return SetViewpoint(vgl, p_viewpoint->yaw / (float) VLC_VIEWPOINT_RADIAN_UNIT,
p_viewpoint->pitch / (float) VLC_VIEWPOINT_RADIAN_UNIT,
- p_viewpoint->roll / (float) VLC_VIEWPOINT_RADIAN_UNIT);
+ p_viewpoint->roll / (float) VLC_VIEWPOINT_RADIAN_UNIT,
+ p_viewpoint->fov / (float) VLC_VIEWPOINT_RADIAN_UNIT,
+ p_viewpoint->zoom / (float) VLC_VIEWPOINT_RADIAN_UNIT);
}
picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned requested_count)
@@ -1101,14 +1113,11 @@ static void getZoomMatrix(float zoom, GLfloat matrix[static 16]) {
}
/* perspective matrix see https://www.opengl.org/sdk/docs/man2/xhtml/gluPerspective.xml */
-static void getProjectionMatrix(float sar, GLfloat matrix[static 16]) {
+static void getProjectionMatrix(float sar, float fovy, GLfloat matrix[static 16]) {
float zFar = 1000;
float zNear = 0.01;
- float fovy = (float) M_PI / 3;
- float d = 1 / tan(fovy / 2);
-
if (fovy > (float) M_PI -0.001)
fovy = (float) M_PI -0.001;
@@ -1568,7 +1577,7 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
|| vgl->fmt.projection_mode == PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD)
{
float sar = (float) vgl->fmt.i_visible_width / vgl->fmt.i_visible_height;
- getProjectionMatrix(sar, projectionMatrix);
+ getProjectionMatrix(sar, vgl->f_fov, projectionMatrix);
getYRotMatrix(vgl->f_teta, yRotMatrix);
getXRotMatrix(vgl->f_phi, xRotMatrix);
getZRotMatrix(vgl->f_roll, zRotMatrix);
--
2.9.3
More information about the vlc-devel
mailing list