Lines Matching refs:mat

107  * \param mat a pointer to a GLmatrix structure.
113 #define TEST_MAT_FLAGS(mat, a) \
114 ((MAT_FLAGS_GEOMETRY & (~(a)) & ((mat)->flags) ) == 0)
208 * \param mat pointer to a GLmatrix structure containing the left multiplication
216 static void matrix_multf( GLmatrix *mat, const GLfloat *m, GLuint flags )
218 mat->flags |= (flags | MAT_DIRTY_TYPE | MAT_DIRTY_INVERSE);
220 if (TEST_MAT_FLAGS(mat, MAT_FLAGS_3D))
221 matmul34( mat->m, mat->m, m );
223 matmul4( mat->m, mat->m, m );
342 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
354 static GLboolean invert_matrix_general( GLmatrix *mat )
356 const GLfloat *m = mat->m;
357 GLfloat *out = mat->inv;
470 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
482 static GLboolean invert_matrix_3d_general( GLmatrix *mat )
484 const GLfloat *in = mat->m;
485 GLfloat *out = mat->inv;
544 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
554 static GLboolean invert_matrix_3d( GLmatrix *mat )
556 const GLfloat *in = mat->m;
557 GLfloat *out = mat->inv;
559 if (!TEST_MAT_FLAGS(mat, MAT_FLAGS_ANGLE_PRESERVING)) {
560 return invert_matrix_3d_general( mat );
563 if (mat->flags & MAT_FLAG_UNIFORM_SCALE) {
584 else if (mat->flags & MAT_FLAG_ROTATION) {
605 if (mat->flags & MAT_FLAG_TRANSLATION) {
627 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
634 static GLboolean invert_matrix_identity( GLmatrix *mat )
636 memcpy( mat->inv, Identity, sizeof(Identity) );
643 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
650 static GLboolean invert_matrix_3d_no_rot( GLmatrix *mat )
652 const GLfloat *in = mat->m;
653 GLfloat *out = mat->inv;
663 if (mat->flags & MAT_FLAG_TRANSLATION) {
675 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
683 static GLboolean invert_matrix_2d_no_rot( GLmatrix *mat )
685 const GLfloat *in = mat->m;
686 GLfloat *out = mat->inv;
695 if (mat->flags & MAT_FLAG_TRANSLATION) {
705 static GLboolean invert_matrix_perspective( GLmatrix *mat )
707 const GLfloat *in = mat->m;
708 GLfloat *out = mat->inv;
734 typedef GLboolean (*inv_mat_func)( GLmatrix *mat );
759 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
768 static GLboolean matrix_invert( GLmatrix *mat )
770 if (inv_mat_tab[mat->type](mat)) {
771 mat->flags &= ~MAT_FLAG_SINGULAR;
774 mat->flags |= MAT_FLAG_SINGULAR;
775 memcpy( mat->inv, Identity, sizeof(Identity) );
796 _math_matrix_rotate( GLmatrix *mat,
864 /* no rotation, leave mat as-is */
962 matrix_multf( mat, m, MAT_FLAG_ROTATION );
968 * \param mat matrix to apply the projection.
976 * Creates the projection matrix and multiplies it with \p mat, marking the
980 _math_matrix_frustum( GLmatrix *mat,
1002 matrix_multf( mat, m, MAT_FLAG_PERSPECTIVE );
1008 * \param mat matrix to apply the projection.
1016 * Creates the projection matrix and multiplies it with \p mat, marking the
1020 _math_matrix_ortho( GLmatrix *mat,
1049 matrix_multf( mat, m, (MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION));
1055 * \param mat matrix.
1060 * Multiplies in-place the elements of \p mat by the scale factors. Checks if
1066 _math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z )
1068 GLfloat *m = mat->m;
1075 mat->flags |= MAT_FLAG_UNIFORM_SCALE;
1077 mat->flags |= MAT_FLAG_GENERAL_SCALE;
1079 mat->flags |= (MAT_DIRTY_TYPE |
1086 * \param mat matrix.
1091 * Adds the translation coordinates to the elements of \p mat in-place. Marks
1096 _math_matrix_translate( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z )
1098 GLfloat *m = mat->m;
1104 mat->flags |= (MAT_FLAG_TRANSLATION |
1132 * \param mat matrix.
1138 _math_matrix_set_identity( GLmatrix *mat )
1140 memcpy( mat->m, Identity, sizeof(Identity) );
1141 memcpy( mat->inv, Identity, sizeof(Identity) );
1143 mat->type = MATRIX_IDENTITY;
1144 mat->flags &= ~(MAT_DIRTY_FLAGS|
1199 * \param mat matrix.
1203 static void analyse_from_scratch( GLmatrix *mat )
1205 const GLfloat *m = mat->m;
1218 mat->flags &= ~MAT_FLAGS_GEOMETRY;
1223 mat->flags |= MAT_FLAG_TRANSLATION;
1228 mat->type = MATRIX_IDENTITY;
1231 mat->type = MATRIX_2D_NO_ROT;
1234 mat->flags |= MAT_FLAG_GENERAL_SCALE;
1241 mat->type = MATRIX_2D;
1246 mat->flags |= MAT_FLAG_GENERAL_SCALE;
1250 mat->flags |= MAT_FLAG_GENERAL_3D;
1252 mat->flags |= MAT_FLAG_ROTATION;
1256 mat->type = MATRIX_3D_NO_ROT;
1262 mat->flags |= MAT_FLAG_UNIFORM_SCALE;
1266 mat->flags |= MAT_FLAG_GENERAL_SCALE;
1276 mat->type = MATRIX_3D;
1281 mat->flags |= MAT_FLAG_UNIFORM_SCALE;
1285 mat->flags |= MAT_FLAG_GENERAL_SCALE;
1293 mat->flags |= MAT_FLAG_ROTATION;
1295 mat->flags |= MAT_FLAG_GENERAL_3D;
1298 mat->flags |= MAT_FLAG_GENERAL_3D; /* shear, etc */
1302 mat->type = MATRIX_PERSPECTIVE;
1303 mat->flags |= MAT_FLAG_GENERAL;
1306 mat->type = MATRIX_GENERAL;
1307 mat->flags |= MAT_FLAG_GENERAL;
1316 static void analyse_from_flags( GLmatrix *mat )
1318 const GLfloat *m = mat->m;
1320 if (TEST_MAT_FLAGS(mat, 0)) {
1321 mat->type = MATRIX_IDENTITY;
1323 else if (TEST_MAT_FLAGS(mat, (MAT_FLAG_TRANSLATION |
1327 mat->type = MATRIX_2D_NO_ROT;
1330 mat->type = MATRIX_3D_NO_ROT;
1333 else if (TEST_MAT_FLAGS(mat, MAT_FLAGS_3D)) {
1337 mat->type = MATRIX_2D;
1340 mat->type = MATRIX_3D;
1347 mat->type = MATRIX_PERSPECTIVE;
1350 mat->type = MATRIX_GENERAL;
1357 * \param mat matrix.
1365 _math_matrix_analyse( GLmatrix *mat )
1367 if (mat->flags & MAT_DIRTY_TYPE) {
1368 if (mat->flags & MAT_DIRTY_FLAGS)
1369 analyse_from_scratch( mat );
1371 analyse_from_flags( mat );
1374 if (mat->inv && (mat->flags & MAT_DIRTY_INVERSE)) {
1375 matrix_invert( mat );
1376 mat->flags &= ~MAT_DIRTY_INVERSE;
1379 mat->flags &= ~(MAT_DIRTY_FLAGS | MAT_DIRTY_TYPE);
1451 * \param mat matrix.
1457 _math_matrix_loadf( GLmatrix *mat, const GLfloat *m )
1459 memcpy( mat->m, m, 16*sizeof(GLfloat) );
1460 mat->flags = (MAT_FLAG_GENERAL | MAT_DIRTY);