ReactOS 0.4.16-dev-297-gc569aee
mmath.h
Go to the documentation of this file.
1/* $Id: mmath.h,v 1.5 1997/12/18 02:54:26 brianp Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version: 2.6
6 * Copyright (C) 1995-1997 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
24/*
25 * $Log: mmath.h,v $
26 * Revision 1.5 1997/12/18 02:54:26 brianp
27 * added Josh Vanderhoof's float->int x86 asm code
28 *
29 * Revision 1.4 1997/10/15 00:36:17 brianp
30 * renamed the FAST/REGULAR_MATH macros
31 *
32 * Revision 1.3 1997/09/29 22:23:54 brianp
33 * added FAST/REGULAR_MATH macros
34 *
35 * Revision 1.2 1997/05/03 00:54:31 brianp
36 * fixed a comment
37 *
38 * Revision 1.1 1997/05/01 01:42:38 brianp
39 * Initial revision
40 *
41 */
42
43
44/*
45 * Faster arithmetic functions. If the FAST_MATH preprocessor symbol is
46 * defined on the command line (-DFAST_MATH) then we'll use some (hopefully)
47 * faster functions for sqrt(), etc.
48 */
49
50
51#ifndef MMATH_H
52#define MMATH_H
53
54#include <math.h>
55
56#define FloatToInt(F) lrintf((F))
57
58extern float gl_sqrt(float x);
59
60#ifdef FAST_MATH
61# define GL_SQRT(X) gl_sqrt(X)
62#else
63# define GL_SQRT(X) sqrt(X)
64#endif
65
66
67/* Normalize a 3-element vector to unit length */
68#define NORMALIZE_3FV( V ) \
69{ \
70 GLfloat len; \
71 len = GL_SQRT(V[0]*V[0]+V[1]*V[1]+V[2]*V[2]); \
72 if (len>0.0001F) { \
73 len = 1.0F / len; \
74 V[0] *= len; \
75 V[1] *= len; \
76 V[2] *= len; \
77 } \
78}
79
80
81extern void gl_init_math(void);
82
83
84#endif
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
float gl_sqrt(float x)
Definition: mmath.c:104
void gl_init_math(void)
Definition: mmath.c:140