cogl/matrix: Init translation matrix using Graphene

This commit is contained in:
Georges Basile Stavracas Neto 2019-02-27 16:13:53 -03:00
parent 3e02a89c2a
commit 8e2658a601
No known key found for this signature in database
GPG Key ID: 886C17EE170D1385

View File

@ -1627,37 +1627,20 @@ cogl_matrix_init_identity (CoglMatrix *matrix)
_COGL_MATRIX_DEBUG_PRINT (matrix); _COGL_MATRIX_DEBUG_PRINT (matrix);
} }
/*
* Set a matrix to the (tx, ty, tz) translation matrix.
*
* @matix matrix.
* @tx x coordinate of the translation vector
* @ty y coordinate of the translation vector
* @tz z coordinate of the translation vector
*/
static void
_cogl_matrix_init_translation (CoglMatrix *matrix,
float tx,
float ty,
float tz)
{
memcpy (matrix, identity, 16 * sizeof (float));
matrix->xw = tx;
matrix->yw = ty;
matrix->zw = tz;
matrix->type = COGL_MATRIX_TYPE_3D;
matrix->flags = MAT_FLAG_TRANSLATION | MAT_DIRTY_INVERSE;
}
void void
cogl_matrix_init_translation (CoglMatrix *matrix, cogl_matrix_init_translation (CoglMatrix *matrix,
float tx, float tx,
float ty, float ty,
float tz) float tz)
{ {
_cogl_matrix_init_translation (matrix, tx, ty, tz); graphene_matrix_t m;
graphene_matrix_init_translate (&m, &GRAPHENE_POINT3D_INIT (tx, ty, tz));
graphene_matrix_to_cogl_matrix (&m, matrix);
matrix->type = COGL_MATRIX_TYPE_3D;
matrix->flags = MAT_FLAG_TRANSLATION | MAT_DIRTY_INVERSE;
_COGL_MATRIX_DEBUG_PRINT (matrix); _COGL_MATRIX_DEBUG_PRINT (matrix);
} }