123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell/* 223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Mesa 3-D graphics library 3bbd287103dad776d8a45c87c4e51fbc26d9b80d5Brian Paul * Version: 7.3 422144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 5bbd287103dad776d8a45c87c4e51fbc26d9b80d5Brian Paul * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * copy of this software and associated documentation files (the "Software"), 923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * to deal in the Software without restriction, including without limitation 1023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * and/or sell copies of the Software, and to permit persons to whom the 1223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Software is furnished to do so, subject to the following conditions: 1322144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 1423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * The above copyright notice and this permission notice shall be included 1523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * in all copies or substantial portions of the Software. 1622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 1723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 2023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 2123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 2423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 2523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell/* 2623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * New (3.1) transformation code written by Keith Whitwell. 2723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 2823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 2923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 3023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#ifndef _M_VECTOR_H_ 3123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define _M_VECTOR_H_ 3223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 33bbd287103dad776d8a45c87c4e51fbc26d9b80d5Brian Paul#include "main/glheader.h" 3423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 3523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 3622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes#define VEC_DIRTY_0 0x1 3723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define VEC_DIRTY_1 0x2 3823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define VEC_DIRTY_2 0x4 3923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define VEC_DIRTY_3 0x8 4023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define VEC_MALLOC 0x10 /* storage field points to self-allocated mem*/ 41cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#define VEC_NOT_WRITEABLE 0x40 /* writable elements to hold clipped data */ 42cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#define VEC_BAD_STRIDE 0x100 /* matches tnl's prefered stride */ 4323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 4423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 4523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define VEC_SIZE_1 VEC_DIRTY_0 4623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define VEC_SIZE_2 (VEC_DIRTY_0|VEC_DIRTY_1) 4723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define VEC_SIZE_3 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2) 4823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define VEC_SIZE_4 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2|VEC_DIRTY_3) 4923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 5023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 5123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 52424507953ca9d41e0dbfcc0399f50315b5671776Brian Paul/** 53424507953ca9d41e0dbfcc0399f50315b5671776Brian Paul * Wrap all the information about vectors up in a struct. Has 5423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * additional fields compared to the other vectors to help us track of 5523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * different vertex sizes, and whether we need to clean columns out 5622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * because they contain non-(0,0,0,1) values. 5723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * 5823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * The start field is used to reserve data for copied vertices at the 5908836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul * end of _mesa_transform_vb, and avoids the need for a multiplication in 6023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * the transformation routines. 6123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 6223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwelltypedef struct { 63424507953ca9d41e0dbfcc0399f50315b5671776Brian Paul GLfloat (*data)[4]; /**< may be malloc'd or point to client data */ 64424507953ca9d41e0dbfcc0399f50315b5671776Brian Paul GLfloat *start; /**< points somewhere inside of <data> */ 65424507953ca9d41e0dbfcc0399f50315b5671776Brian Paul GLuint count; /**< size of the vector (in elements) */ 66424507953ca9d41e0dbfcc0399f50315b5671776Brian Paul GLuint stride; /**< stride from one element to the next (in bytes) */ 67424507953ca9d41e0dbfcc0399f50315b5671776Brian Paul GLuint size; /**< 2-4 for vertices and 1-4 for texcoords */ 68800b14cd378ed708a29230d92031ac7b6ad6a286Brian Paul GLbitfield flags; /**< bitmask of VEC_x flags */ 69424507953ca9d41e0dbfcc0399f50315b5671776Brian Paul void *storage; /**< self-allocated storage */ 701f75c2daeae71985ec3b9fd8f1431aa33ae35d1eBrian Paul GLuint storage_count; /**< storage size in elements */ 7123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell} GLvector4f; 7223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 7323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 74800b14cd378ed708a29230d92031ac7b6ad6a286Brian Paulextern void _mesa_vector4f_init( GLvector4f *v, GLbitfield flags, 7523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell GLfloat (*storage)[4] ); 76800b14cd378ed708a29230d92031ac7b6ad6a286Brian Paulextern void _mesa_vector4f_alloc( GLvector4f *v, GLbitfield flags, 7723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell GLuint count, GLuint alignment ); 7808836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paulextern void _mesa_vector4f_free( GLvector4f *v ); 79424507953ca9d41e0dbfcc0399f50315b5671776Brian Paulextern void _mesa_vector4f_print( const GLvector4f *v, const GLubyte *, GLboolean ); 8008836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paulextern void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint nr, GLuint elt ); 8123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 8223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 83424507953ca9d41e0dbfcc0399f50315b5671776Brian Paul/** 8423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Given vector <v>, return a pointer (cast to <type *> to the <i>-th element. 8523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * 8623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * End up doing a lot of slow imuls if not careful. 8723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 8823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define VEC_ELT( v, type, i ) \ 8923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell ( (type *) ( ((GLbyte *) ((v)->data)) + (i) * (v)->stride) ) 9023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 9123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 9223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#endif 93