[mutter/gbsneto/graphene2: 30/45] cogl/matrix: Frustum with graphene
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/graphene2: 30/45] cogl/matrix: Frustum with graphene
- Date: Sat, 7 Sep 2019 11:19:45 +0000 (UTC)
commit 10f1d3118cb70655b2e7212f72726f3f7e114694
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Feb 27 19:00:02 2019 -0300
cogl/matrix: Frustum with graphene
cogl/cogl/cogl-matrix.c | 46 ++++++++++------------------------------------
1 file changed, 10 insertions(+), 36 deletions(-)
---
diff --git a/cogl/cogl/cogl-matrix.c b/cogl/cogl/cogl-matrix.c
index 9953ab4ea..99e455201 100644
--- a/cogl/cogl/cogl-matrix.c
+++ b/cogl/cogl/cogl-matrix.c
@@ -392,41 +392,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);
-}
-
void
cogl_matrix_frustum (CoglMatrix *matrix,
float left,
@@ -436,7 +401,16 @@ 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, m;
+
+ graphene_matrix_init_frustum (&frustum, left, right, bottom, top, z_near, z_far);
+
+ cogl_matrix_to_graphene_matrix (matrix, &m);
+ graphene_matrix_transpose (&m, &m);
+
+ graphene_matrix_multiply (&m, &frustum, &m);
+ graphene_matrix_to_cogl_matrix (&m, matrix);
+
_COGL_MATRIX_DEBUG_PRINT (matrix);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]