[cogl/wip/virtual-framebuffer: 3/22] stash: Add cogl_matrix_orthographic



commit 6ff86f4a113ea0622f683d3786a44ee39fe6b2ad
Author: Robert Bragg <robert linux intel com>
Date:   Fri Nov 18 14:07:17 2011 +0000

    stash: Add cogl_matrix_orthographic

 cogl/cogl-matrix.c                                 |   47 ++++++++++++-------
 cogl/cogl-matrix.h                                 |   32 +++++++++++++
 .../cogl-2.0-experimental-sections.txt             |    2 +-
 3 files changed, 63 insertions(+), 18 deletions(-)
---
diff --git a/cogl/cogl-matrix.c b/cogl/cogl-matrix.c
index 396017c..92d13b8 100644
--- a/cogl/cogl-matrix.c
+++ b/cogl/cogl-matrix.c
@@ -1420,31 +1420,31 @@ cogl_matrix_perspective (CoglMatrix *matrix,
  * MAT_FLAG_GENERAL_SCALE and MAT_FLAG_TRANSLATION flags.
  */
 static void
-_cogl_matrix_ortho (CoglMatrix *matrix,
-                    float left,
-                    float right,
-                    float bottom,
-                    float top,
-                    float nearval,
-                    float farval)
+_cogl_matrix_orthographic (CoglMatrix *matrix,
+                           float x_1,
+                           float y_1,
+                           float x_2,
+                           float y_2,
+                           float nearval,
+                           float farval)
 {
   float m[16];
 
-#define M(row,col)  m[col*4+row]
-  M (0,0) = 2.0f / (right-left);
+#define M(row, col)  m[col * 4 + row]
+  M (0,0) = 2.0f / (x_2 - x_1);
   M (0,1) = 0.0f;
   M (0,2) = 0.0f;
-  M (0,3) = -(right+left) / (right-left);
+  M (0,3) = -(x_2 + x_1) / (x_2 - x_1);
 
   M (1,0) = 0.0f;
-  M (1,1) = 2.0f / (top-bottom);
+  M (1,1) = 2.0f / (y_1 - y_2);
   M (1,2) = 0.0f;
-  M (1,3) = -(top+bottom) / (top-bottom);
+  M (1,3) = -(y_1 + y_2) / (y_1 - y_2);
 
   M (2,0) = 0.0f;
   M (2,1) = 0.0f;
-  M (2,2) = -2.0f / (farval-nearval);
-  M (2,3) = -(farval+nearval) / (farval-nearval);
+  M (2,2) = -2.0f / (farval - nearval);
+  M (2,3) = -(farval + nearval) / (farval - nearval);
 
   M (3,0) = 0.0f;
   M (3,1) = 0.0f;
@@ -1463,10 +1463,23 @@ cogl_matrix_ortho (CoglMatrix *matrix,
                    float right,
                    float bottom,
                    float top,
-                   float near_val,
-                   float far_val)
+                   float near,
+                   float far)
+{
+  _cogl_matrix_orthographic (matrix, left, top, right, bottom, near, far);
+  _COGL_MATRIX_DEBUG_PRINT (matrix);
+}
+
+void
+cogl_matrix_orthographic (CoglMatrix *matrix,
+                          float x_1,
+                          float y_1,
+                          float x_2,
+                          float y_2,
+                          float near,
+                          float far)
 {
-  _cogl_matrix_ortho (matrix, left, right, bottom, top, near_val, far_val);
+  _cogl_matrix_orthographic (matrix, x_1, y_1, x_2, y_2, near, far);
   _COGL_MATRIX_DEBUG_PRINT (matrix);
 }
 
diff --git a/cogl/cogl-matrix.h b/cogl/cogl-matrix.h
index 0bb3e75..78a6531 100644
--- a/cogl/cogl-matrix.h
+++ b/cogl/cogl-matrix.h
@@ -294,6 +294,36 @@ cogl_matrix_perspective (CoglMatrix *matrix,
                          float       z_near,
                          float       z_far);
 
+#ifdef COGL_ENABLE_EXPERIMENTAL_API
+#define cogl_matrix_orthographic cogl_matrix_orthographic_EXP
+/**
+ * cogl_matrix_orthographic:
+ * @matrix: A 4x4 transformation matrix
+ * @x_1: The x coordinate for the first vertical clipping plane
+ * @y_1: The y coordinate for the first horizontal clipping plane
+ * @x_2: The x coordinate for the second vertical clipping plane
+ * @y_2: The y coordinate for the second horizontal clipping plane
+ * @near: The <emphasis>distance</emphasis> to the near clipping
+ *   plane (will be <emphasis>negative</emphasis> if the plane is
+ *   behind the viewer)
+ * @far: The <emphasis>distance</emphasis> to the far clipping
+ *   plane (will be <emphasis>negative</emphasis> if the plane is
+ *   behind the viewer)
+ *
+ * Multiplies @matrix by a parallel projection matrix.
+ *
+ * Since: 1.10
+ */
+void
+cogl_matrix_orthographic (CoglMatrix *matrix,
+                          float x_1,
+                          float y_1,
+                          float x_2,
+                          float y_2,
+                          float near,
+                          float far);
+#endif
+
 /**
  * cogl_matrix_ortho:
  * @matrix: A 4x4 transformation matrix
@@ -307,6 +337,8 @@ cogl_matrix_perspective (CoglMatrix *matrix,
  *   the plane is behind the viewer)
  *
  * Multiplies @matrix by a parallel projection matrix.
+ *
+ * Deprecated: 1.10: Use cogl_matrix_orthographic()
  */
 void
 cogl_matrix_ortho (CoglMatrix *matrix,
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 f2dd72c..8421263 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
@@ -479,7 +479,7 @@ cogl_matrix_copy
 cogl_matrix_equal
 cogl_matrix_free
 cogl_matrix_frustum
-cogl_matrix_ortho
+cogl_matrix_orthographic
 cogl_matrix_perspective
 cogl_matrix_look_at
 cogl_matrix_multiply



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]