3 * Mesa 3-D graphics library
6 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
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:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
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.
27 * New (3.1) transformation code written by Keith Whitwell.
34 #include "main/glheader.h"
35 #include "main/mtypes.h" /* hack for GLchan */
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 */
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)
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.
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.
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 */
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
);
87 * Given vector <v>, return a pointer (cast to <type *> to the <i>-th element.
89 * End up doing a lot of slow imuls if not careful.
91 #define VEC_ELT( v, type, i ) \
92 ( (type *) ( ((GLbyte *) ((v)->data)) + (i) * (v)->stride) )