summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-11-03 15:31:46 +0000
committerNeil Roberts <neil@linux.intel.com>2011-11-16 16:32:11 +0000
commitd2fd168351aa86949fc84b7be95ec786eb739261 (patch)
treead8421462e3a4fcf2c7b8b3f94d8f72d33e880fb
parent037c0aa88cb8eb74f21ce24c80467b909028d2f6 (diff)
downloadcogl-d2fd168351aa86949fc84b7be95ec786eb739261.tar.gz
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>
-rw-r--r--cogl/cogl-matrix.c17
-rw-r--r--cogl/cogl-matrix.h12
-rw-r--r--doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt1
-rw-r--r--doc/reference/cogl/cogl-sections.txt1
4 files changed, 29 insertions, 2 deletions
diff --git a/cogl/cogl-matrix.c b/cogl/cogl-matrix.c
index abb0a926..396017c5 100644
--- a/cogl/cogl-matrix.c
+++ b/cogl/cogl-matrix.c
@@ -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);
+}
diff --git a/cogl/cogl-matrix.h b/cogl/cogl-matrix.h
index 14e92a3b..0bb3e75e 100644
--- a/cogl/cogl-matrix.h
+++ b/cogl/cogl-matrix.h
@@ -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 ())
diff --git a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
index 0073408e..b0b8ae7a 100644
--- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
+++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
@@ -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
diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt
index 1bbb50b0..77240494 100644
--- a/doc/reference/cogl/cogl-sections.txt
+++ b/doc/reference/cogl/cogl-sections.txt
@@ -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