Remove mesa include directories, be stricter about include paths.
[mesa.git] / src / mesa / math / m_vector.h
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 * New (3.1) transformation code written by Keith Whitwell.
28 */
29
30
31 #ifndef _M_VECTOR_H_
32 #define _M_VECTOR_H_
33
34 #include "main/glheader.h"
35 #include "main/mtypes.h" /* hack for GLchan */
36
37
38 #define VEC_DIRTY_0 0x1
39 #define VEC_DIRTY_1 0x2
40 #define VEC_DIRTY_2 0x4
41 #define VEC_DIRTY_3 0x8
42 #define VEC_MALLOC 0x10 /* storage field points to self-allocated mem*/
43 #define VEC_NOT_WRITEABLE 0x40 /* writable elements to hold clipped data */
44 #define VEC_BAD_STRIDE 0x100 /* matches tnl's prefered stride */
45
46
47 #define VEC_SIZE_1 VEC_DIRTY_0
48 #define VEC_SIZE_2 (VEC_DIRTY_0|VEC_DIRTY_1)
49 #define VEC_SIZE_3 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2)
50 #define VEC_SIZE_4 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2|VEC_DIRTY_3)
51
52
53
54 /* Wrap all the information about vectors up in a struct. Has
55 * additional fields compared to the other vectors to help us track of
56 * different vertex sizes, and whether we need to clean columns out
57 * because they contain non-(0,0,0,1) values.
58 *
59 * The start field is used to reserve data for copied vertices at the
60 * end of _mesa_transform_vb, and avoids the need for a multiplication in
61 * the transformation routines.
62 */
63 typedef struct {
64 GLfloat (*data)[4]; /* may be malloc'd or point to client data */
65 GLfloat *start; /* points somewhere inside of <data> */
66 GLuint count; /* size of the vector (in elements) */
67 GLuint stride; /* stride from one element to the next (in bytes) */
68 GLuint size; /* 2-4 for vertices and 1-4 for texcoords */
69 GLuint flags; /* which columns are dirty */
70 void *storage; /* self-allocated storage */
71 } GLvector4f;
72
73
74 extern void _mesa_vector4f_init( GLvector4f *v, GLuint flags,
75 GLfloat (*storage)[4] );
76 extern void _mesa_vector4f_alloc( GLvector4f *v, GLuint flags,
77 GLuint count, GLuint alignment );
78 extern void _mesa_vector4f_free( GLvector4f *v );
79 extern void _mesa_vector4f_print( GLvector4f *v, GLubyte *, GLboolean );
80 extern void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint nr, GLuint elt );
81
82
83
84
85
86 /*
87 * Given vector <v>, return a pointer (cast to <type *> to the <i>-th element.
88 *
89 * End up doing a lot of slow imuls if not careful.
90 */
91 #define VEC_ELT( v, type, i ) \
92 ( (type *) ( ((GLbyte *) ((v)->data)) + (i) * (v)->stride) )
93
94
95 #endif