~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/extras/Mesa/src/math/m_matrix.h

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 * Mesa 3-D graphics library
 
4
 * Version:  3.5
 
5
 *
 
6
 * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
 
7
 *
 
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:
 
14
 *
 
15
 * The above copyright notice and this permission notice shall be included
 
16
 * in all copies or substantial portions of the Software.
 
17
 *
 
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.
 
24
 */
 
25
 
 
26
 
 
27
#ifndef _M_MATRIX_H
 
28
#define _M_MATRIX_H
 
29
 
 
30
 
 
31
 
 
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.
 
34
 */
 
35
#define MAT_SX 0
 
36
#define MAT_SY 5
 
37
#define MAT_SZ 10
 
38
#define MAT_TX 12
 
39
#define MAT_TY 13
 
40
#define MAT_TZ 14
 
41
 
 
42
/*
 
43
 * Different kinds of 4x4 transformation matrices:
 
44
 */
 
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 */
 
52
 
 
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
 
65
 
 
66
#define MAT_FLAGS_ANGLE_PRESERVING (MAT_FLAG_ROTATION | \
 
67
                                    MAT_FLAG_TRANSLATION | \
 
68
                                    MAT_FLAG_UNIFORM_SCALE)
 
69
 
 
70
#define MAT_FLAGS_LENGTH_PRESERVING (MAT_FLAG_ROTATION | \
 
71
                                     MAT_FLAG_TRANSLATION)
 
72
 
 
73
#define MAT_FLAGS_3D (MAT_FLAG_ROTATION | \
 
74
                      MAT_FLAG_TRANSLATION | \
 
75
                      MAT_FLAG_UNIFORM_SCALE | \
 
76
                      MAT_FLAG_GENERAL_SCALE | \
 
77
                      MAT_FLAG_GENERAL_3D)
 
78
 
 
79
#define MAT_FLAGS_GEOMETRY (MAT_FLAG_GENERAL | \
 
80
                            MAT_FLAG_ROTATION | \
 
81
                            MAT_FLAG_TRANSLATION | \
 
82
                            MAT_FLAG_UNIFORM_SCALE | \
 
83
                            MAT_FLAG_GENERAL_SCALE | \
 
84
                            MAT_FLAG_GENERAL_3D | \
 
85
                            MAT_FLAG_PERSPECTIVE | \
 
86
                            MAT_FLAG_SINGULAR)
 
87
 
 
88
#define MAT_DIRTY          (MAT_DIRTY_TYPE | \
 
89
                            MAT_DIRTY_FLAGS | \
 
90
                            MAT_DIRTY_INVERSE)
 
91
 
 
92
#define TEST_MAT_FLAGS(mat, a)  \
 
93
    ((MAT_FLAGS_GEOMETRY & (~(a)) & ((mat)->flags) ) == 0)
 
94
 
 
95
 
 
96
typedef struct {
 
97
   GLfloat *m;          /* 16-byte aligned */
 
98
   GLfloat *inv;        /* optional, 16-byte aligned */
 
99
   GLuint flags;
 
100
   GLuint type;         /* one of the MATRIX_* values */
 
101
} GLmatrix;
 
102
 
 
103
 
 
104
 
 
105
 
 
106
extern void
 
107
_math_matrix_ctr( GLmatrix *m );
 
108
 
 
109
extern void
 
110
_math_matrix_dtr( GLmatrix *m );
 
111
 
 
112
extern void
 
113
_math_matrix_alloc_inv( GLmatrix *m );
 
114
 
 
115
extern void
 
116
_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b );
 
117
 
 
118
extern void
 
119
_math_matrix_mul_floats( GLmatrix *dest, const GLfloat *b );
 
120
 
 
121
extern void
 
122
_math_matrix_loadf( GLmatrix *mat, const GLfloat *m );
 
123
 
 
124
extern void
 
125
_math_matrix_translate( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z );
 
126
 
 
127
extern void
 
128
_math_matrix_rotate( GLmatrix *m, GLfloat angle,
 
129
                     GLfloat x, GLfloat y, GLfloat z );
 
130
 
 
131
extern void
 
132
_math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z );
 
133
 
 
134
extern void
 
135
_math_matrix_ortho( GLmatrix *mat,
 
136
                    GLfloat left, GLfloat right,
 
137
                    GLfloat bottom, GLfloat top,
 
138
                    GLfloat nearval, GLfloat farval );
 
139
 
 
140
extern void
 
141
_math_matrix_frustum( GLmatrix *mat,
 
142
                      GLfloat left, GLfloat right,
 
143
                      GLfloat bottom, GLfloat top,
 
144
                      GLfloat nearval, GLfloat farval );
 
145
 
 
146
extern void
 
147
_math_matrix_set_identity( GLmatrix *dest );
 
148
 
 
149
extern void
 
150
_math_matrix_copy( GLmatrix *to, const GLmatrix *from );
 
151
 
 
152
extern void
 
153
_math_matrix_analyse( GLmatrix *mat );
 
154
 
 
155
extern void
 
156
_math_matrix_print( const GLmatrix *m );
 
157
 
 
158
 
 
159
 
 
160
 
 
161
/* Related functions that don't actually operate on GLmatrix structs:
 
162
 */
 
163
extern void
 
164
_math_transposef( GLfloat to[16], const GLfloat from[16] );
 
165
 
 
166
extern void
 
167
_math_transposed( GLdouble to[16], const GLdouble from[16] );
 
168
 
 
169
extern void
 
170
_math_transposefd( GLfloat to[16], const GLdouble from[16] );
 
171
 
 
172
 
 
173
 
 
174
 
 
175
#endif