cogl-matrix: Add a public cogl_matrix_transpose()

This function takes a single matrix argument and replaces the matrix
with its transpose.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts 2011-11-03 15:31:46 +00:00
parent 037c0aa88c
commit d2fd168351
4 changed files with 29 additions and 2 deletions

View File

@ -1689,7 +1689,6 @@ cogl_matrix_init_from_quaternion (CoglMatrix *matrix,
_cogl_matrix_init_from_quaternion (matrix, quaternion);
}
#if 0
/*
* Transpose a float matrix.
*/
@ -1713,7 +1712,6 @@ _cogl_matrix_util_transposef (float to[16], const float from[16])
to[14] = from[11];
to[15] = from[15];
}
#endif
void
cogl_matrix_view_2d_in_frustum (CoglMatrix *matrix,
@ -2122,3 +2120,18 @@ cogl_matrix_look_at (CoglMatrix *matrix,
cogl_matrix_multiply (matrix, matrix, &tmp);
}
void
cogl_matrix_transpose (CoglMatrix *matrix)
{
float new_values[16];
/* We don't need to do anything if the matrix is the identity matrix */
if (!(matrix->flags & MAT_DIRTY_TYPE) &&
matrix->type == COGL_MATRIX_TYPE_IDENTITY)
return;
_cogl_matrix_util_transposef (new_values, cogl_matrix_get_array (matrix));
cogl_matrix_init_from_array (matrix, new_values);
}

View File

@ -653,6 +653,18 @@ cogl_matrix_project_points (const CoglMatrix *matrix,
gboolean
cogl_matrix_is_identity (const CoglMatrix *matrix);
/**
* cogl_matrix_transpose:
* @matrix: A #CoglMatrix
*
* Replaces @matrix with its transpose. Ie, every element (i,j) in the
* new matrix is taken from element (j,i) in the old matrix.
*
* Since: 1.10
*/
void
cogl_matrix_transpose (CoglMatrix *matrix);
#ifdef _COGL_SUPPORTS_GTYPE_INTEGRATION
#define COGL_GTYPE_TYPE_MATRIX (cogl_gtype_matrix_get_type ())

View File

@ -486,6 +486,7 @@ cogl_matrix_multiply
cogl_matrix_rotate
cogl_matrix_translate
cogl_matrix_scale
cogl_matrix_transpose
cogl_matrix_get_array
cogl_matrix_get_inverse
cogl_matrix_transform_point

View File

@ -463,6 +463,7 @@ cogl_matrix_multiply
cogl_matrix_rotate
cogl_matrix_translate
cogl_matrix_scale
cogl_matrix_transpose
cogl_matrix_init_from_array
cogl_matrix_get_array
cogl_matrix_get_inverse