From d0590de9e8a39b6bdab3fab59bc62ffa8b167cf4 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 27 Feb 2019 19:03:59 -0300 Subject: [PATCH] cogl/matrix: Apply perspective with Graphene --- cogl/cogl/cogl-matrix.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cogl/cogl/cogl-matrix.c b/cogl/cogl/cogl-matrix.c index 7f0d3176c..97034ee7a 100644 --- a/cogl/cogl/cogl-matrix.c +++ b/cogl/cogl/cogl-matrix.c @@ -421,15 +421,16 @@ cogl_matrix_perspective (CoglMatrix *matrix, float z_near, float z_far) { - float ymax = z_near * tan (fov_y * G_PI / 360.0); + graphene_matrix_t perspective, m; + + graphene_matrix_init_perspective (&perspective, fov_y, aspect, z_near, z_far); + + cogl_matrix_to_graphene_matrix (matrix, &m); + graphene_matrix_transpose (&m, &m); + + graphene_matrix_multiply (&m, &perspective, &m); + graphene_matrix_to_cogl_matrix (&m, matrix); - cogl_matrix_frustum (matrix, - -ymax * aspect, /* left */ - ymax * aspect, /* right */ - -ymax, /* bottom */ - ymax, /* top */ - z_near, - z_far); _COGL_MATRIX_DEBUG_PRINT (matrix); }