3
* Mesa 3-D graphics library
6
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
8
* Permission is hereby granted, free of charge, to any person obtaining a
9
* copy of this software and associated documentation files (the "Software"),
10
* to deal in the Software without restriction, including without limitation
11
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
* and/or sell copies of the Software, and to permit persons to whom the
13
* Software is furnished to do so, subject to the following conditions:
15
* The above copyright notice and this permission notice shall be included
16
* in all copies or substantial portions of the Software.
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
/* Give symbolic names to some of the entries in the matrix to help
33
* out with the rework of the viewport_map as a matrix transform.
43
* Different kinds of 4x4 transformation matrices:
45
#define MATRIX_GENERAL 0 /* general 4x4 matrix */
46
#define MATRIX_IDENTITY 1 /* identity matrix */
47
#define MATRIX_3D_NO_ROT 2 /* ortho projection and others... */
48
#define MATRIX_PERSPECTIVE 3 /* perspective projection matrix */
49
#define MATRIX_2D 4 /* 2-D transformation */
50
#define MATRIX_2D_NO_ROT 5 /* 2-D scale & translate only */
51
#define MATRIX_3D 6 /* 3-D transformation */
53
#define MAT_FLAG_IDENTITY 0
54
#define MAT_FLAG_GENERAL 0x1
55
#define MAT_FLAG_ROTATION 0x2
56
#define MAT_FLAG_TRANSLATION 0x4
57
#define MAT_FLAG_UNIFORM_SCALE 0x8
58
#define MAT_FLAG_GENERAL_SCALE 0x10
59
#define MAT_FLAG_GENERAL_3D 0x20
60
#define MAT_FLAG_PERSPECTIVE 0x40
61
#define MAT_FLAG_SINGULAR 0x80
62
#define MAT_DIRTY_TYPE 0x100
63
#define MAT_DIRTY_FLAGS 0x200
64
#define MAT_DIRTY_INVERSE 0x400
66
#define MAT_FLAGS_ANGLE_PRESERVING (MAT_FLAG_ROTATION | \
67
MAT_FLAG_TRANSLATION | \
68
MAT_FLAG_UNIFORM_SCALE)
70
#define MAT_FLAGS_LENGTH_PRESERVING (MAT_FLAG_ROTATION | \
73
#define MAT_FLAGS_3D (MAT_FLAG_ROTATION | \
74
MAT_FLAG_TRANSLATION | \
75
MAT_FLAG_UNIFORM_SCALE | \
76
MAT_FLAG_GENERAL_SCALE | \
79
#define MAT_FLAGS_GEOMETRY (MAT_FLAG_GENERAL | \
81
MAT_FLAG_TRANSLATION | \
82
MAT_FLAG_UNIFORM_SCALE | \
83
MAT_FLAG_GENERAL_SCALE | \
84
MAT_FLAG_GENERAL_3D | \
85
MAT_FLAG_PERSPECTIVE | \
88
#define MAT_DIRTY (MAT_DIRTY_TYPE | \
92
#define TEST_MAT_FLAGS(mat, a) \
93
((MAT_FLAGS_GEOMETRY & (~(a)) & ((mat)->flags) ) == 0)
97
GLfloat *m; /* 16-byte aligned */
98
GLfloat *inv; /* optional, 16-byte aligned */
100
GLuint type; /* one of the MATRIX_* values */
107
_math_matrix_ctr( GLmatrix *m );
110
_math_matrix_dtr( GLmatrix *m );
113
_math_matrix_alloc_inv( GLmatrix *m );
116
_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b );
119
_math_matrix_mul_floats( GLmatrix *dest, const GLfloat *b );
122
_math_matrix_loadf( GLmatrix *mat, const GLfloat *m );
125
_math_matrix_translate( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z );
128
_math_matrix_rotate( GLmatrix *m, GLfloat angle,
129
GLfloat x, GLfloat y, GLfloat z );
132
_math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z );
135
_math_matrix_ortho( GLmatrix *mat,
136
GLfloat left, GLfloat right,
137
GLfloat bottom, GLfloat top,
138
GLfloat nearval, GLfloat farval );
141
_math_matrix_frustum( GLmatrix *mat,
142
GLfloat left, GLfloat right,
143
GLfloat bottom, GLfloat top,
144
GLfloat nearval, GLfloat farval );
147
_math_matrix_set_identity( GLmatrix *dest );
150
_math_matrix_copy( GLmatrix *to, const GLmatrix *from );
153
_math_matrix_analyse( GLmatrix *mat );
156
_math_matrix_print( const GLmatrix *m );
161
/* Related functions that don't actually operate on GLmatrix structs:
164
_math_transposef( GLfloat to[16], const GLfloat from[16] );
167
_math_transposed( GLdouble to[16], const GLdouble from[16] );
170
_math_transposefd( GLfloat to[16], const GLdouble from[16] );