cogl/matrix: Apply perspective with Graphene

This commit is contained in:
Georges Basile Stavracas Neto 2019-02-27 19:03:59 -03:00
parent 7c909d184c
commit d0590de9e8
No known key found for this signature in database
GPG Key ID: 886C17EE170D1385

View File

@ -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);
}