From da3fd3d210b73c665e8b1d3982b861539b6cd020 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 3 Dec 2009 12:29:26 -0800 Subject: Add C++ wrappers for gluDeterminan4_4m and gluInverse4_4m --- include/glu3.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/include/glu3.h b/include/glu3.h index 3dff417..9f082ce 100644 --- a/include/glu3.h +++ b/include/glu3.h @@ -581,15 +581,22 @@ void gluTranspose4m(GLUmat4 *result, const GLUmat4 *m); /** * Calculate the determinant of a matrix. + * + * \sa gluDeterminant4 (C++) */ GLfloat gluDeterminant4_4m(const GLUmat4 *m); /** * Calculate the inverse of a matrix. * + * Inverts the matrix \c m and stores the result in \c result. If \c m is + * not invertable, \c result is not modified + * * \return * If the matrix is invertable (i.e., the determinant is not zero), \c GL_TRUE * is returned. Otherwise GL_FALSE is returned. + * + * \sa gluInverse4 (C++) */ GLboolean gluInverse4_4m(GLUmat4 *result, const GLUmat4 *m); @@ -875,6 +882,55 @@ inline GLUmat4 gluLookAt(const GLUvec4 &eye, const GLUvec4 ¢er, return result; } +/** + * Calculate the determinant of a matrix. + * + * \sa gluDeterminant4_4m + */ +inline GLfloat gluDeterminant4(const GLUmat4 &m) +{ + return gluDeterminant4_4m(& m); +} + +/** + * Calculate the inverse of a matrix. + * + * Inverts the matrix \c m and stores the result in \c result. If \c m is + * not invertable, \c result is not modified + * + * \return + * If the matrix is invertable (i.e., the determinant is not zero), \c GL_TRUE + * is returned. Otherwise GL_FALSE is returned. + * + * \sa gluInverse4_4m + */ +inline GLboolean gluInverse4(GLUmat4 &result, const GLUmat4 &m) +{ + return gluInverse4_4m(& result, & m); +} + +/** + * Calculate the inverse of a matrix. + * + * \return + * The inverse of the matrix \c m. If \c m is not invertable, the return + * result is undefined. + * + * \warning + * This function is really only safe when the input matrix is known to be + * invertable. Nearly all well behaved transformation matrices fall into this + * category. + * + * \sa gluInverse4_4m + */ +inline GLUmat4 gluInverse4(const GLUmat4 &m) +{ + GLUmat4 result; + + gluInverse4_4m(& result, & m); + return result; +} + #endif /* __cplusplus */ #include "glu3_scalar.h" -- cgit v1.2.3