2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
26 * New (3.1) transformation code written by Keith Whitwell.
33 #include "main/glheader.h"
36 #define VEC_DIRTY_0 0x1
37 #define VEC_DIRTY_1 0x2
38 #define VEC_DIRTY_2 0x4
39 #define VEC_DIRTY_3 0x8
40 #define VEC_MALLOC 0x10 /* storage field points to self-allocated mem*/
41 #define VEC_NOT_WRITEABLE 0x40 /* writable elements to hold clipped data */
42 #define VEC_BAD_STRIDE 0x100 /* matches tnl's prefered stride */
45 #define VEC_SIZE_1 VEC_DIRTY_0
46 #define VEC_SIZE_2 (VEC_DIRTY_0|VEC_DIRTY_1)
47 #define VEC_SIZE_3 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2)
48 #define VEC_SIZE_4 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2|VEC_DIRTY_3)
53 * Wrap all the information about vectors up in a struct. Has
54 * additional fields compared to the other vectors to help us track
55 * different vertex sizes, and whether we need to clean columns out
56 * because they contain non-(0,0,0,1) values.
58 * The start field is used to reserve data for copied vertices at the
59 * end of _mesa_transform_vb, and avoids the need for a multiplication in
60 * the transformation routines.
63 GLfloat (*data
)[4]; /**< may be malloc'd or point to client data */
64 GLfloat
*start
; /**< points somewhere inside of GLvector4f::data */
65 GLuint count
; /**< size of the vector (in elements) */
66 GLuint stride
; /**< stride from one element to the next (in bytes) */
67 GLuint size
; /**< 2-4 for vertices and 1-4 for texcoords */
68 GLbitfield flags
; /**< bitmask of VEC_x flags */
69 void *storage
; /**< self-allocated storage */
70 GLuint storage_count
; /**< storage size in elements */
74 extern void _mesa_vector4f_init( GLvector4f
*v
, GLbitfield flags
,
75 GLfloat (*storage
)[4] );
76 extern void _mesa_vector4f_alloc( GLvector4f
*v
, GLbitfield flags
,
77 GLuint count
, GLuint alignment
);
78 extern void _mesa_vector4f_free( GLvector4f
*v
);
79 extern void _mesa_vector4f_print( const GLvector4f
*v
, const GLubyte
*, GLboolean
);
80 extern void _mesa_vector4f_clean_elem( GLvector4f
*vec
, GLuint nr
, GLuint elt
);
84 * Given vector <v>, return a pointer (cast to <type *> to the <i>-th element.
86 * End up doing a lot of slow imuls if not careful.
88 #define VEC_ELT( v, type, i ) \
89 ( (type *) ( ((GLbyte *) ((v)->data)) + (i) * (v)->stride) )