8eedbdb94249f8125d679c6ccc5ca58e6bc99b6d
1 /* $Id: m_matrix.h,v 1.1 2000/11/16 21:05:41 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 /* Give symbolic names to some of the entries in the matrix to help
34 * out with the rework of the viewport_map as a matrix transform.
44 * Different kinds of 4x4 transformation matrices:
46 #define MATRIX_GENERAL 0 /* general 4x4 matrix */
47 #define MATRIX_IDENTITY 1 /* identity matrix */
48 #define MATRIX_3D_NO_ROT 2 /* ortho projection and others... */
49 #define MATRIX_PERSPECTIVE 3 /* perspective projection matrix */
50 #define MATRIX_2D 4 /* 2-D transformation */
51 #define MATRIX_2D_NO_ROT 5 /* 2-D scale & translate only */
52 #define MATRIX_3D 6 /* 3-D transformation */
54 #define MAT_FLAG_IDENTITY 0
55 #define MAT_FLAG_GENERAL 0x1
56 #define MAT_FLAG_ROTATION 0x2
57 #define MAT_FLAG_TRANSLATION 0x4
58 #define MAT_FLAG_UNIFORM_SCALE 0x8
59 #define MAT_FLAG_GENERAL_SCALE 0x10
60 #define MAT_FLAG_GENERAL_3D 0x20
61 #define MAT_FLAG_PERSPECTIVE 0x40
62 #define MAT_FLAG_SINGULAR 0x80
63 #define MAT_DIRTY_TYPE 0x100
64 #define MAT_DIRTY_FLAGS 0x200
65 #define MAT_DIRTY_INVERSE 0x400
67 #define MAT_FLAGS_ANGLE_PRESERVING (MAT_FLAG_ROTATION | \
68 MAT_FLAG_TRANSLATION | \
69 MAT_FLAG_UNIFORM_SCALE)
71 #define MAT_FLAGS_LENGTH_PRESERVING (MAT_FLAG_ROTATION | \
74 #define MAT_FLAGS_3D (MAT_FLAG_ROTATION | \
75 MAT_FLAG_TRANSLATION | \
76 MAT_FLAG_UNIFORM_SCALE | \
77 MAT_FLAG_GENERAL_SCALE | \
80 #define MAT_FLAGS_GEOMETRY (MAT_FLAG_GENERAL | \
82 MAT_FLAG_TRANSLATION | \
83 MAT_FLAG_UNIFORM_SCALE | \
84 MAT_FLAG_GENERAL_SCALE | \
85 MAT_FLAG_GENERAL_3D | \
86 MAT_FLAG_PERSPECTIVE | \
89 #define MAT_DIRTY (MAT_DIRTY_TYPE | \
93 #define TEST_MAT_FLAGS(mat, a) \
94 ((MAT_FLAGS_GEOMETRY & (~(a)) & ((mat)->flags) ) == 0)
98 GLfloat
*m
; /* 16-byte aligned */
99 GLfloat
*inv
; /* optional, 16-byte aligned */
101 GLuint type
; /* one of the MATRIX_* values */
108 _math_matrix_ctr( GLmatrix
*m
);
111 _math_matrix_dtr( GLmatrix
*m
);
114 _math_matrix_alloc_inv( GLmatrix
*m
);
117 _math_matrix_mul_matrix( GLmatrix
*dest
, const GLmatrix
*a
, const GLmatrix
*b
);
120 _math_matrix_mul_floats( GLmatrix
*dest
, const GLfloat
*b
);
123 _math_matrix_loadf( GLmatrix
*mat
, const GLfloat
*m
);
126 _math_matrix_translate( GLmatrix
*mat
, GLfloat x
, GLfloat y
, GLfloat z
);
129 _math_matrix_rotate( GLmatrix
*m
, GLfloat angle
,
130 GLfloat x
, GLfloat y
, GLfloat z
);
133 _math_matrix_scale( GLmatrix
*mat
, GLfloat x
, GLfloat y
, GLfloat z
);
136 _math_matrix_ortho( GLmatrix
*mat
,
137 GLfloat left
, GLfloat right
,
138 GLfloat bottom
, GLfloat top
,
139 GLfloat nearval
, GLfloat farval
);
142 _math_matrix_frustrum( GLmatrix
*mat
,
143 GLfloat left
, GLfloat right
,
144 GLfloat bottom
, GLfloat top
,
145 GLfloat nearval
, GLfloat farval
);
148 _math_matrix_set_identity( GLmatrix
*dest
);
151 _math_matrix_copy( GLmatrix
*to
, const GLmatrix
*from
);
154 _math_matrix_analyze( GLmatrix
*mat
);
157 _math_matrix_print( const GLmatrix
*m
);
162 /* Related functions that don't actually operate on GLmatrix structs:
165 _math_transposef( GLfloat to
[16], const GLfloat from
[16] );
168 _math_transposed( GLdouble to
[16], const GLdouble from
[16] );
171 _math_transposefd( GLfloat to
[16], const GLdouble from
[16] );