Debian Codegraph @

debian/external_deps/fetk/sg/src/gl/xform.h

raw
1 /* $Id: xform.h,v 1.2 2000/10/27 15:21:40 mholst Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 2.0
6 * Copyright (C) 1995-1996 Brian Paul
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #ifndef XFORM_H
24 #define XFORM_H
25
26
27 #include "types.h"
28
29
30 /*
31 * Transform a point (column vector) by a matrix: Q = M * P
32 */
33 #define TRANSFORM_POINT( Q, M, P ) \
34 Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12] * P[3]; \
35 Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13] * P[3]; \
36 Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14] * P[3]; \
37 Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15] * P[3];
38
39
40 /*
41 * Transform a normal (row vector) by a matrix: [NX NY NZ] = N * MAT
42 */
43 #define TRANSFORM_NORMAL( NX, NY, NZ, N, MAT ) \
44 NX = N[0] * MAT[0] + N[1] * MAT[1] + N[2] * MAT[2]; \
45 NY = N[0] * MAT[4] + N[1] * MAT[5] + N[2] * MAT[6]; \
46 NZ = N[0] * MAT[8] + N[1] * MAT[9] + N[2] * MAT[10]; \
47
48
49
50 extern void gl_xform_points_4fv( GLuint n, GLfloat q[][4], const GLfloat m[16],
51 GLfloat p[][4] );
52
53
54 extern void gl_xform_points_3fv( GLuint n, GLfloat q[][4], const GLfloat m[16],
55 GLfloat p[][3] );
56
57
58 extern void gl_xform_normals_3fv( GLuint n, GLfloat v[][3],
59 const GLfloat m[16],
60 GLfloat u[][3], GLboolean normalize );
61
62
63 extern void gl_transform_vector( GLfloat u[4],
64 const GLfloat v[4], const GLfloat m[16] );
65
66
67 extern void gl_xform_texcoords_4fv( GLuint n, GLfloat tc[][4],
68 const GLfloat m[16] );
69
70
71 #endif