summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2020-04-28 10:18:47 -0700
committerMarge Bot <eric+marge@anholt.net>2020-05-14 15:35:43 +0000
commit29f10ede71ffe8352bdfda154f3994542094bcfb (patch)
treeae2cdc863fcc78644aa2b9ed49e92583262ed344
parentc731f2ab63d001d47995e3f5e0e8f5c74d5a2e55 (diff)
mesa: Add function to calculate an orthographic projection
Unlike the existing _math_matrix_ortho, the new _math_float_ortho function just stores the calculated matrix in an array of floats. It does not multiply the new matrix with data already stored. text data bss dec hex filename 12243486 1344936 1290748 14879170 e309c2 before/lib64/dri/i965_dri.so 12243510 1344936 1290748 14879194 e309da after/lib64/dri/i965_dri.so Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/856>
-rw-r--r--src/mesa/math/m_matrix.c42
-rw-r--r--src/mesa/math/m_matrix.h6
2 files changed, 38 insertions, 10 deletions
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
index 31b7665a3ba..0202c6fa1f2 100644
--- a/src/mesa/math/m_matrix.c
+++ b/src/mesa/math/m_matrix.c
@@ -1007,9 +1007,9 @@ _math_matrix_frustum( GLmatrix *mat,
}
/**
- * Apply an orthographic projection matrix.
+ * Create an orthographic projection matrix.
*
- * \param mat matrix to apply the projection.
+ * \param m float array in which to store the project matrix
* \param left left clipping plane coordinate.
* \param right right clipping plane coordinate.
* \param bottom bottom clipping plane coordinate.
@@ -1017,17 +1017,15 @@ _math_matrix_frustum( GLmatrix *mat,
* \param nearval distance to the near clipping plane.
* \param farval distance to the far clipping plane.
*
- * Creates the projection matrix and multiplies it with \p mat, marking the
- * MAT_FLAG_GENERAL_SCALE and MAT_FLAG_TRANSLATION flags.
+ * Creates the projection matrix and stored the values in \p m. As with other
+ * OpenGL matrices, the data is stored in column-major ordering.
*/
void
-_math_matrix_ortho( GLmatrix *mat,
- GLfloat left, GLfloat right,
- GLfloat bottom, GLfloat top,
- GLfloat nearval, GLfloat farval )
+_math_float_ortho(float *m,
+ float left, float right,
+ float bottom, float top,
+ float nearval, float farval)
{
- GLfloat m[16];
-
#define M(row,col) m[col*4+row]
M(0,0) = 2.0F / (right-left);
M(0,1) = 0.0F;
@@ -1049,7 +1047,31 @@ _math_matrix_ortho( GLmatrix *mat,
M(3,2) = 0.0F;
M(3,3) = 1.0F;
#undef M
+}
+
+/**
+ * Apply an orthographic projection matrix.
+ *
+ * \param mat matrix to apply the projection.
+ * \param left left clipping plane coordinate.
+ * \param right right clipping plane coordinate.
+ * \param bottom bottom clipping plane coordinate.
+ * \param top top clipping plane coordinate.
+ * \param nearval distance to the near clipping plane.
+ * \param farval distance to the far clipping plane.
+ *
+ * Creates the projection matrix and multiplies it with \p mat, marking the
+ * MAT_FLAG_GENERAL_SCALE and MAT_FLAG_TRANSLATION flags.
+ */
+void
+_math_matrix_ortho( GLmatrix *mat,
+ GLfloat left, GLfloat right,
+ GLfloat bottom, GLfloat top,
+ GLfloat nearval, GLfloat farval )
+{
+ GLfloat m[16];
+ _math_float_ortho(m, left, right, bottom, top, nearval, farval);
matrix_multf( mat, m, (MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION));
}
diff --git a/src/mesa/math/m_matrix.h b/src/mesa/math/m_matrix.h
index c34d9e3022f..6de9e1a84cd 100644
--- a/src/mesa/math/m_matrix.h
+++ b/src/mesa/math/m_matrix.h
@@ -110,6 +110,12 @@ extern void
_math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z );
extern void
+_math_float_ortho(float *m,
+ float left, float right,
+ float bottom, float top,
+ float nearval, float farval);
+
+extern void
_math_matrix_ortho( GLmatrix *mat,
GLfloat left, GLfloat right,
GLfloat bottom, GLfloat top,