[mutter/gbsneto/graphene-matrix: 7/57] cogl/matrix: Frustum with graphene matrices
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/graphene-matrix: 7/57] cogl/matrix: Frustum with graphene matrices
- Date: Thu, 24 Sep 2020 11:43:34 +0000 (UTC)
commit 08708ee03fc0e3c6e55e999356712ed59856939f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Sep 10 11:56:54 2020 -0300
cogl/matrix: Frustum with graphene matrices
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
cogl/cogl/cogl-matrix.c | 53 ++++++++++++++++---------------------------------
1 file changed, 17 insertions(+), 36 deletions(-)
---
diff --git a/cogl/cogl/cogl-matrix.c b/cogl/cogl/cogl-matrix.c
index 5494d18fd8..4060199a47 100644
--- a/cogl/cogl/cogl-matrix.c
+++ b/cogl/cogl/cogl-matrix.c
@@ -1191,41 +1191,6 @@ cogl_matrix_rotate_euler (CoglMatrix *matrix,
cogl_matrix_multiply (matrix, matrix, &rotation_transform);
}
-/*
- * Apply a perspective projection matrix.
- *
- * Creates the projection matrix and multiplies it with matrix, marking the
- * MAT_FLAG_PERSPECTIVE flag.
- */
-static void
-_cogl_matrix_frustum (CoglMatrix *matrix,
- float left,
- float right,
- float bottom,
- float top,
- float nearval,
- float farval)
-{
- float x, y, a, b, c, d;
- float m[16];
-
- x = (2.0f * nearval) / (right - left);
- y = (2.0f * nearval) / (top - bottom);
- a = (right + left) / (right - left);
- b = (top + bottom) / (top - bottom);
- c = -(farval + nearval) / ( farval - nearval);
- d = -(2.0f * farval * nearval) / (farval - nearval); /* error? */
-
-#define M(row,col) m[col*4+row]
- M (0,0) = x; M (0,1) = 0.0f; M (0,2) = a; M (0,3) = 0.0f;
- M (1,0) = 0.0f; M (1,1) = y; M (1,2) = b; M (1,3) = 0.0f;
- M (2,0) = 0.0f; M (2,1) = 0.0f; M (2,2) = c; M (2,3) = d;
- M (3,0) = 0.0f; M (3,1) = 0.0f; M (3,2) = -1.0f; M (3,3) = 0.0f;
-#undef M
-
- matrix_multiply_array_with_flags (matrix, m, MAT_FLAG_PERSPECTIVE);
-}
-
void
cogl_matrix_frustum (CoglMatrix *matrix,
float left,
@@ -1235,7 +1200,23 @@ cogl_matrix_frustum (CoglMatrix *matrix,
float z_near,
float z_far)
{
- _cogl_matrix_frustum (matrix, left, right, bottom, top, z_near, z_far);
+ graphene_matrix_t frustum;
+ graphene_matrix_t m;
+ unsigned long flags;
+
+ flags = matrix->flags;
+
+ cogl_matrix_to_graphene_matrix (matrix, &m);
+ graphene_matrix_init_frustum (&frustum,
+ left, right,
+ bottom, top,
+ z_near, z_far);
+ graphene_matrix_multiply (&frustum, &m, &m);
+ graphene_matrix_to_cogl_matrix (&m, matrix);
+
+ flags |= MAT_FLAG_PERSPECTIVE | MAT_DIRTY_TYPE | MAT_DIRTY_INVERSE;
+ matrix->flags = flags;
+
_COGL_MATRIX_DEBUG_PRINT (matrix);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]