diff options
author | Robert Bragg <robert@linux.intel.com> | 2011-06-30 22:15:08 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2011-07-04 15:31:50 +0100 |
commit | d74cf9de81f1241c8c3f2419d62f7519c6fbd6f2 (patch) | |
tree | 863198913715992c4f38c4547628474a93869980 | |
parent | 8bfde524f895ec33d216fdd81b32ef62599469b2 (diff) | |
download | cogl-d74cf9de81f1241c8c3f2419d62f7519c6fbd6f2.tar.gz |
matrix: Adds cogl_matrix_is_identity API
This adds a function called cogl_matrix_is_identity that can determine
if a given matrix is an identity matrix or not.
Signed-off-by: Neil Roberts <neil@linux.intel.com>
-rw-r--r-- | cogl/cogl-matrix.c | 10 | ||||
-rw-r--r-- | cogl/cogl-matrix.h | 12 | ||||
-rw-r--r-- | doc/reference/cogl-2.0-experimental/cogl-sections.txt | 1 | ||||
-rw-r--r-- | doc/reference/cogl/cogl-sections.txt | 1 |
4 files changed, 24 insertions, 0 deletions
diff --git a/cogl/cogl-matrix.c b/cogl/cogl-matrix.c index 51c98fb8..4ceece7d 100644 --- a/cogl/cogl-matrix.c +++ b/cogl/cogl-matrix.c @@ -2041,3 +2041,13 @@ cogl_matrix_project_points (const CoglMatrix *matrix, n_points); } } + +gboolean +cogl_matrix_is_identity (const CoglMatrix *matrix) +{ + if (!(matrix->flags & MAT_DIRTY_TYPE) && + matrix->type == COGL_MATRIX_TYPE_IDENTITY) + return TRUE; + else + return memcmp (matrix, identity, sizeof (float) * 16) == 0; +} diff --git a/cogl/cogl-matrix.h b/cogl/cogl-matrix.h index 903d2ea6..a2c23854 100644 --- a/cogl/cogl-matrix.h +++ b/cogl/cogl-matrix.h @@ -585,6 +585,18 @@ cogl_matrix_project_points (const CoglMatrix *matrix, #endif /* COGL_ENABLE_EXPERIMENTAL_API */ +/** + * cogl_matrix_is_identity: + * @matrix: A #CoglMatrix + * + * Determines if the given matrix is an identity matrix. + * + * Returns: %TRUE if @matrix is an identity matrix else %FALSE + * Since: 1.8 + */ +gboolean +cogl_matrix_is_identity (const 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-sections.txt b/doc/reference/cogl-2.0-experimental/cogl-sections.txt index 02f79315..1f7216fa 100644 --- a/doc/reference/cogl-2.0-experimental/cogl-sections.txt +++ b/doc/reference/cogl-2.0-experimental/cogl-sections.txt @@ -387,6 +387,7 @@ cogl_matrix_scale cogl_matrix_init_from_array cogl_matrix_get_array cogl_matrix_get_inverse +cogl_matrix_is_identity </SECTION> <FILE>cogl-euler</FILE> diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt index c737a8b4..1bbb50b0 100644 --- a/doc/reference/cogl/cogl-sections.txt +++ b/doc/reference/cogl/cogl-sections.txt @@ -469,6 +469,7 @@ cogl_matrix_get_inverse cogl_matrix_transform_point cogl_matrix_project_points cogl_matrix_transform_points +cogl_matrix_is_identity </SECTION> <SECTION> |