[cogl/wip/neil/pipeline-uniforms: 12/15] cogl-matrix: Add a public cogl_matrix_transpose()
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/neil/pipeline-uniforms: 12/15] cogl-matrix: Add a public cogl_matrix_transpose()
- Date: Fri, 4 Nov 2011 16:28:42 +0000 (UTC)
commit 0f22e6df07e615677f356f9eb4a00d8d4f4ccbd4
Author: Neil Roberts <neil linux intel com>
Date: Thu Nov 3 15:31:46 2011 +0000
cogl-matrix: Add a public cogl_matrix_transpose()
This function takes a single matrix argument and replaces the matrix
with its transpose.
cogl/cogl-matrix.c | 17 +++++++++++++++--
cogl/cogl-matrix.h | 12 ++++++++++++
.../cogl-2.0-experimental-sections.txt | 1 +
doc/reference/cogl/cogl-sections.txt | 1 +
4 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/cogl/cogl-matrix.c b/cogl/cogl-matrix.c
index abb0a92..396017c 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 14e92a3..0bb3e75 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 f8a1185..5555126 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 1bbb50b..7724049 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]