summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2009-10-25 22:30:22 -0700
committerIan Romanick <ian.d.romanick@intel.com>2009-10-25 22:30:22 -0700
commita44406cdfb1568b497ddf2176660f4fadf792085 (patch)
tree24eac3cae2439bba62c2423c3a384a99a60538bb /include
parent0a375b908418ea64bd7a817413b4b14d74fca6ab (diff)
Add several functions to calculate projection matrixes.
This commit adds: gluFrustum6f, gluOrtho4f, and gluOrtho6f. These functions match glFrustum, gluOrtho2d (from classic GLU), and glOrtho.
Diffstat (limited to 'include')
-rw-r--r--include/glu3.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/include/glu3.h b/include/glu3.h
index 43fcd8b..1c31c15 100644
--- a/include/glu3.h
+++ b/include/glu3.h
@@ -436,6 +436,44 @@ void gluLookAt4v(GLUmat4 *result, const GLUvec4 *eye, const GLUvec4 *center,
const GLUvec4 *up);
/**
+ * \name Projection matrix
+ *
+ * Functions that generate various common projection matrixes.
+ */
+/*@{*/
+/**
+ * Generate a perspective projection matrix
+ *
+ * \param result Location to store the calculated matrix
+ * \param left Coordinate for the left clipping plane
+ * \param right Coordinate for the right clipping plane
+ * \param top Coordinate for the top clipping plane
+ * \param bottom Coordinate for the bottom clipping plane
+ * \param near Distance to the near plane
+ * \param far Distance to the far plane
+ *
+ * The matrix calculated is:
+ *
+ * \f{eqnarray*}{
+ * M &=&
+ * \left( \begin{tabular}{cccc}
+ * ${2 * near} \over {right - left}$ & $0$ & $ {{right + left} \over {right - left}}$ & $0$\\
+ * $0$ & ${2 * near} \over {top - bottom}$ & $ {{top + bottom} \over {top - bottom}}$ & $0$ \\
+ * $0$ & $0$ & $-{{far + near} \over {far - near}}$ & $-{{2 * far * near} \over {far - near}}$ \\
+ * $0$ & $0$ & $-1$ & $0$ \\
+ * \end{tabular} \right) \\
+ * \f}
+ *
+ * If \c left = \c right, \c top = \c bottom, or \c near = \c far, the function
+ * returns without writing any value to \c result.
+ *
+ * If either\c near or \c far are negative, the function returns without
+ * writing any value to \c result.
+ */
+void gluFrustum6f(GLUmat4 *result, GLfloat left, GLfloat right, GLfloat top,
+ GLfloat bottom, GLfloat near, GLfloat far);
+
+/**
* Calculate a perspective projection matrix
*
* \param result Storage for the resulting matrix.
@@ -463,6 +501,70 @@ void gluPerspective4f(GLUmat4 *result, GLfloat fovy, GLfloat aspect,
GLfloat near, GLfloat far);
/**
+ * Generate an orthographic projection matrix
+ *
+ * \param result Location to store the calculated matrix
+ * \param left Coordinate for the left clipping plane
+ * \param right Coordinate for the right clipping plane
+ * \param top Coordinate for the top clipping plane
+ * \param bottom Coordinate for the bottom clipping plane
+ *
+ * The matrix calculated is:
+ *
+ * \f{eqnarray*}{
+ * M &=&
+ * \left( \begin{tabular}{cccc}
+ * $2 \over {right - left}$ & $0$ & $0$ & $-{{right + left} \over {right - left}}$ \\
+ * $0$ & $2 \over {top - bottom}$ & $0$ & $-{{top + bottom} \over {top - bottom}}$ \\
+ * $0$ & $0$ & $-1$ & $0$ \\
+ * $0$ & $0$ & $0$ & $1$ \\
+ * \end{tabular} \right) \\
+ * \f}
+ *
+ * If \c left = \c right or \c top = \c bottom the function returns without
+ * writing any value to \c result.
+ *
+ * This function is identical to calling \c gluOrtho6f with \c near = -1 and
+ * \c far = 1.
+ *
+ * \sa gluOrtho6f
+ */
+void gluOrtho4f(GLUmat4 *result, GLfloat left, GLfloat right, GLfloat top,
+ GLfloat bottom);
+
+/**
+ * Generate an orthographic projection matrix
+ *
+ * \param result Location to store the calculated matrix
+ * \param left Coordinate for the left clipping plane
+ * \param right Coordinate for the right clipping plane
+ * \param top Coordinate for the top clipping plane
+ * \param bottom Coordinate for the bottom clipping plane
+ * \param near Distance to the near plane
+ * \param far Distance to the far plane
+ *
+ * The matrix calculated is:
+ *
+ * \f{eqnarray*}{
+ * M &=&
+ * \left( \begin{tabular}{cccc}
+ * $2 \over {right - left}$ & $0$ & $0$ & $-{{right + left} \over {right - left}}$ \\
+ * $0$ & $2 \over {top - bottom}$ & $0$ & $-{{top + bottom} \over {top - bottom}}$ \\
+ * $0$ & $0$ & $-2 \over {far - near}$ & $-{{far + near} \over {far - near}}$ \\
+ * $0$ & $0$ & $0$ & $1$ \\
+ * \end{tabular} \right) \\
+ * \f}
+ *
+ * If \c left = \c right, \c top = \c bottom, or \c near = \c far, the function
+ * returns without writing any value to \c result.
+ *
+ * \s gluOrtho4f
+ */
+void gluOrtho6f(GLUmat4 *result, GLfloat left, GLfloat right, GLfloat top,
+ GLfloat bottom, GLfloat near, GLfloat far);
+/*@}*/
+
+/**
* Calculate the transpose of a matrix.
*/
void gluTranspose4m(GLUmat4 *result, const GLUmat4 *m);